Gambas is an Ide available on linux that let us to develop window & web application using Visual Basic syntax.We can visually design design
window form add required widgets & code for required events of widget just like Visual Basic studio.Gambas 3.11 is latest release.Lets build simple calculator using gambas.
I designed calculator form using textbox & buttons. My screen look like below
Code behind for Fmain i.e. Fmail.class look like
' Gambas class file
v1 As Float = 0
opr As String = ""
Public Sub Form_Open()
End
Public Sub BtnZero_Click()
vbDisplay.Text = vbDisplay.Text & "0"
End
Public Sub BtnSeven_Click()
vbDisplay.Text = Val(vbDisplay.Text & "7")
End
Public Sub BtnEight_Click()
vbDisplay.Text = Val(vbDisplay.Text & "8")
End
Public Sub BtnNine_Click()
vbDisplay.Text = Val(vbDisplay.Text & "9")
End
Public Sub BtnFour_Click()
vbDisplay.Text = Val(vbDisplay.Text & "4")
End
Public Sub BtnFive_Click()
vbDisplay.Text = Val(vbDisplay.Text & "5")
End
Public Sub BtnSix_Click()
vbDisplay.Text = Val(vbDisplay.Text & "6")
End
Public Sub BtnOne_Click()
vbDisplay.Text = Val(vbDisplay.Text & "1")
End
Public Sub BtnTwo_Click()
vbDisplay.Text = Val(vbDisplay.Text & "2")
End
Public Sub BtnThree_Click()
vbDisplay.Text = Val(vbDisplay.Text & "3")
End
Public Sub BtnPlus_Click()
v1 = vbDisplay.Text
opr = "a"
vbDisplay.Text = "0"
End
Public Sub BtnEqual_Click()
Select opr
Case "a"
vbDisplay.Text = v1 + Val(vbDisplay.Text)
Case "s"
vbDisplay.Text = v1 - Val(vbDisplay.Text)
Case "m"
vbDisplay.Text = v1 * Val(vbDisplay.Text)
Case "p"
vbDisplay.Text = (v1 * Val(vbDisplay.Text)) / 100
Case "d"
If Val(vbDisplay.Text) <> 0 Then
vbDisplay.Text = v1 / Val(vbDisplay.Text)
Endif
End Select
End
Public Sub BtnSubstract_Click()
v1 = vbDisplay.Text
opr = "s"
vbDisplay.Text = ""
End
Public Sub BtnMultiply_Click()
v1 = vbDisplay.Text
opr = "m"
vbDisplay.Text = ""
End
Public Sub BtnDivide_Click()
v1 = vbDisplay.Text
opr = "d"
vbDisplay.Text = ""
End
Public Sub BtnDot_Click()
vbDisplay.Text = vbDisplay.Text & "."
End
Public Sub BtnPercent_Click()
v1 = vbDisplay.Text
opr = "p"
vbDisplay.Text = ""
End
Public Sub BtnClear_Click()
v1 = 0
opr = ""
vbDisplay.Text = ""
End
Public Sub BtnSign_Click()
vbDisplay.Text = -1 * Val(vbDisplay.Text)
End
Go to Debug > Run and execute our Calc.
Now we have functional simple calculator in Gambas.
You can create executable & then create package, In my case i choose .deb package from list of available options,Then installed new package for test purpose .
I got my new calc with default Duck icon visible in my gnome menu by searching for calc.I was able to run the calc.
My calc's package name was conflux-gambas.deb.I was able to remove package from using apt-get.
apt-get remove conflux-gambas
Thus we can create a desktop application using Gambas & distribute it across various linux platform.
window form add required widgets & code for required events of widget just like Visual Basic studio.Gambas 3.11 is latest release.Lets build simple calculator using gambas.
I designed calculator form using textbox & buttons. My screen look like below
Code behind for Fmain i.e. Fmail.class look like
' Gambas class file
v1 As Float = 0
opr As String = ""
Public Sub Form_Open()
End
Public Sub BtnZero_Click()
vbDisplay.Text = vbDisplay.Text & "0"
End
Public Sub BtnSeven_Click()
vbDisplay.Text = Val(vbDisplay.Text & "7")
End
Public Sub BtnEight_Click()
vbDisplay.Text = Val(vbDisplay.Text & "8")
End
Public Sub BtnNine_Click()
vbDisplay.Text = Val(vbDisplay.Text & "9")
End
Public Sub BtnFour_Click()
vbDisplay.Text = Val(vbDisplay.Text & "4")
End
Public Sub BtnFive_Click()
vbDisplay.Text = Val(vbDisplay.Text & "5")
End
Public Sub BtnSix_Click()
vbDisplay.Text = Val(vbDisplay.Text & "6")
End
Public Sub BtnOne_Click()
vbDisplay.Text = Val(vbDisplay.Text & "1")
End
Public Sub BtnTwo_Click()
vbDisplay.Text = Val(vbDisplay.Text & "2")
End
Public Sub BtnThree_Click()
vbDisplay.Text = Val(vbDisplay.Text & "3")
End
Public Sub BtnPlus_Click()
v1 = vbDisplay.Text
opr = "a"
vbDisplay.Text = "0"
End
Public Sub BtnEqual_Click()
Select opr
Case "a"
vbDisplay.Text = v1 + Val(vbDisplay.Text)
Case "s"
vbDisplay.Text = v1 - Val(vbDisplay.Text)
Case "m"
vbDisplay.Text = v1 * Val(vbDisplay.Text)
Case "p"
vbDisplay.Text = (v1 * Val(vbDisplay.Text)) / 100
Case "d"
If Val(vbDisplay.Text) <> 0 Then
vbDisplay.Text = v1 / Val(vbDisplay.Text)
Endif
End Select
End
Public Sub BtnSubstract_Click()
v1 = vbDisplay.Text
opr = "s"
vbDisplay.Text = ""
End
Public Sub BtnMultiply_Click()
v1 = vbDisplay.Text
opr = "m"
vbDisplay.Text = ""
End
Public Sub BtnDivide_Click()
v1 = vbDisplay.Text
opr = "d"
vbDisplay.Text = ""
End
Public Sub BtnDot_Click()
vbDisplay.Text = vbDisplay.Text & "."
End
Public Sub BtnPercent_Click()
v1 = vbDisplay.Text
opr = "p"
vbDisplay.Text = ""
End
Public Sub BtnClear_Click()
v1 = 0
opr = ""
vbDisplay.Text = ""
End
Public Sub BtnSign_Click()
vbDisplay.Text = -1 * Val(vbDisplay.Text)
End
Go to Debug > Run and execute our Calc.
Now we have functional simple calculator in Gambas.
You can create executable & then create package, In my case i choose .deb package from list of available options,Then installed new package for test purpose .
I got my new calc with default Duck icon visible in my gnome menu by searching for calc.I was able to run the calc.
My calc's package name was conflux-gambas.deb.I was able to remove package from using apt-get.
apt-get remove conflux-gambas
Thus we can create a desktop application using Gambas & distribute it across various linux platform.
Source Code can be found at https://github.com/gitsangramdesai/gambas-execuatable