How to Create a Temperature Converter Application in Basic4Android
Full Source code:
#Region Project Attributes
#ApplicationLabel: Temperature Converter
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim EditText1 As EditText
Dim Spinner1 As Spinner
Dim Label2 As Label
Dim cel,fah As Double
Dim selected As String
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("1")
Spinner1.Prompt="Please select"
Spinner1.Add("°C")
Spinner1.Add("°F")
EditText1.Text=""
selected="°C"
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button1_Click
If selected="°F" Then
check
fah=EditText1.Text
cel=Round2(fah-32/(1.8),3)
Else
check
cel=EditText1.text
End If
Label2.Text="The result is :" & cel &" °C"
End Sub
Sub Button2_Click
If selected="°C" Then
check
cel=EditText1.Text
fah=Round2((cel*1.8)+32,3)
Else
check
fah=EditText1.text
End If
Label2.Text="The result is : " & fah &" °F"
End Sub
Sub Spinner1_ItemClick (Position As Int, Value As Object)
selected=Value
End Sub
Sub check
If edittext1.Text="" Then
Msgbox("Please Donot let textbox empty","Please")
EditText1.Text=0
cel=0
fah=0
End If
End Sub
Full Source Zip file::sabinkhanal.com.np/temperature.zip