It doesn't look like there is much interest in my VB6 under Linux presentation so I thought I would chat about Gambas instead. If you like VB classic, you're going to love Gambas. (sorry Windows users) Here is a chart building example to introduce some of the language concepts and use.
Gambas is a Basic development environment supporting the Basic programming language with object extensions. It includes an IDE, a BASIC compiler, an interpreter, an archiver and a graphical user interface component. Gambas is an interpreted language, with no "just-in-time" or other compilation to native code at all. Although not intended to be a Visual Basic clone, it has a visual rapid application development interface like VB. With Gambas, you can quickly design your program GUI with QT or GTK+, access MySQL, PostgreSQL, Firebird, ODBC and SQLite databases, pilot KDE applications with
DCOP, translate your program into any language, create network applications easily, make 3D OpenGL applications, make CGI web applications, and so on...
What Is Gambas? (VB on X)
Online DocumentationGambas vs.Visual Basic (Differences between the language implementations)
Supported operating systems include Linux and FreeBSD, OpenBSD.
Entry Form Class' Gambas class file
PUBLIC SUB btnClose_Click()
ME.Close
END
PUBLIC SUB btnDraw_Click()
DIM total AS Integer
total = 10
WITH FormChart
.value = NEW Float[]
.total = total
.value.Resize(total + 1)
TRY .value[1] = Val(textbox1.Text)
TRY .value[2] = Val(textbox2.Text)
TRY .value[3] = Val(textbox3.Text)
TRY .value[4] = Val(textbox4.Text)
TRY .value[5] = Val(textbox5.Text)
TRY .value[6] = Val(textbox6.Text)
TRY .value[7] = Val(textbox7.Text)
TRY .value[8] = Val(textbox8.Text)
TRY .value[9] = Val(textbox9.Text)
TRY .value[10] = Val(textbox10.Text)
.Show
END WITH
END
PUBLIC SUB Form_Open()
END
PUBLIC SUB TextBox6_KeyPress()
END
FormData.form# Gambas Form File 2.0
{ Form Form
MoveScaled(29.75,16.375,50.375,43.25)
Text = ("Chart example")
Border = Window.Fixed
{ TextLabel1 TextLabel
MoveScaled(3,2,6.75,3.25)
Text = ("Data 1")
}
{ TextLabel2 TextLabel
MoveScaled(3,6,6.75,3.25)
Text = ("Data 2")
}
{ TextLabel3 TextLabel
MoveScaled(3,10,6.75,3.25)
Text = ("Data 3")
}
{ TextLabel4 TextLabel
MoveScaled(3,14,6.75,3.25)
Text = ("Data 4")
}
{ TextLabel5 TextLabel
MoveScaled(3,18,6.75,3.25)
Text = ("Data 5")
}
{ TextLabel6 TextLabel
MoveScaled(3,22,6.75,3.25)
Text = ("Data 6")
}
{ TextLabel7 TextLabel
MoveScaled(3,26,6.75,3.25)
Text = ("Data 7")
}
{ TextLabel8 TextLabel
MoveScaled(3,30,6.75,3.25)
Text = ("Data 8")
}
{ TextLabel9 TextLabel
MoveScaled(3,34,6.75,3.25)
Text = ("Data 9")
}
{ TextLabel10 TextLabel
MoveScaled(3,38,6.75,3.25)
Text = ("Data 10")
}
{ TextBox1 TextBox
MoveScaled(11,2,14,3)
Text = ("")
}
{ TextBox2 TextBox
MoveScaled(11,6,14,3)
Text = ("")
}
{ TextBox3 TextBox
MoveScaled(11,10,14,3)
Text = ("")
}
{ TextBox4 TextBox
MoveScaled(11,14,14,3)
Text = ("")
}
{ TextBox5 TextBox
MoveScaled(11,18,14,3)
Text = ("")
}
{ TextBox6 TextBox
MoveScaled(11,22,14,3)
Text = ("")
}
{ TextBox7 TextBox
MoveScaled(11,26,14,3)
Text = ("")
}
{ TextBox8 TextBox
MoveScaled(11,30,14,3)
Text = ("")
}
{ TextBox9 TextBox
MoveScaled(11,34,14,3)
Text = ("")
}
{ TextBox10 TextBox
MoveScaled(11,38,14,3)
Text = ("")
}
{ btnDraw Button
MoveScaled(30,2,19,4)
Text = ("&Draw it")
}
{ btnClose Button
MoveScaled(30,7,19,4)
Text = ("&Close")
}
}
Chart Class' Gambas class file
' ======================================
' This example is to make a bar chart
' using DrawingArea
' may be it can help you to make a chart
' if you have any question you can send to
' yudi@kecoak.or.id
' Thank You
PUBLIC total AS Integer
PUBLIC value AS Float[]
PUBLIC SUB btnClose_Click()
ME.Close
END
PUBLIC SUB _new()
ME.Center
END
PUBLIC SUB Form_Open()
Draw_Chart
END
PUBLIC SUB Draw_Chart()
DIM i AS Integer
DIM skala_1 AS Integer
DIM skala_2 AS Integer
DIM distance_x AS Float
DIM distance_y AS Float
DIM width_draw AS Integer
DIM tot AS Integer
DIM colors AS Integer[]
DIM bottom AS Integer
DIM sumdata AS Integer
colors = NEW Integer[]
colors.Resize(total + 1)
FOR i = 1 TO total
sumdata = sumdata + value[i]
NEXT
IF sumdata = 0 THEN sumdata = 1
FOR i = 1 TO total
value[i] = (value[i] / sumdata) * 10
NEXT
drwchart.Clear
draw.Begin(drwchart)
skala_1 = drwchart.ClientH / 11
distance_y = drwchart.ClientH - skala_1
bottom = distance_y + 8
FOR i = 0 TO 100 STEP 10
draw.ForeColor = color.black
draw.Text(i, 0, distance_y)
draw.Line(25, distance_y + 8, drwchart.clientw, distance_y + 8)
distance_y = distance_y - skala_1
NEXT
draw.Line(30, 0, 30, drwchart.ClientH)
skala_2 = (drwchart.ClientW - 30) \ 10
distance_x = skala_2 + 30
width_draw = skala_2 / 2
FOR i = 1 TO Total
draw.LineWidth = 1
draw.ForeColor = color.Black
draw.Text(i, distance_x - (width_draw / 2) - 4, drwchart.ClientH - 20)
draw.Line(distance_x - (width_draw / 2), 0, distance_x - (width_draw / 2), drwchart.ClientH - skala_1 + 8)
draw.LineWidth = width_draw
draw.ForeColor = color.RGB(i * 100, i * 10, i * 50)
colors[i] = draw.ForeColor
tot = skala_1 * value[i] + skala_1 - 8
draw.Line(distance_x - (width_draw / 2), bottom, distance_x - (width_draw / 2), drwchart.ClientH - tot)
distance_x = distance_x + skala_2
NEXT
DRAW.End
END
PUBLIC SUB btnAbout_Click()
DIM i AS String
i = "<h2>Example to make bar chart</h2>\n"
i = i & "This example has made by : " & Chr(10)
i = i & " Yudi Astira" & Chr(10)
i = i & " yudi@kecoak.or.id" & Chr(10)
i = i & " necrose #hdteam on Dal.Net" & Chr(10)
i = i & "Thank You"
message.Info(i, "&Close")
END
PUBLIC SUB drwChart_Draw()
END
FormChart.form# Gambas Form File 2.0
{ Form Form
MoveScaled(0,0,72,50)
Background = &HFFEFBF&
Text = ("Example to make a Bar Chart")
Border = Window.Fixed
{ bg PictureBox
MoveScaled(1,1,70.25,43.375)
Background = &HFFFFFF&
Border = Border.Plain
}
{ drwChart DrawingArea
MoveScaled(2,2,69,41)
Background = &HFFFFFF&
Cached = True
}
{ btnClose Button
MoveScaled(56.25,45,15,4)
Text = ("&Close")
}
{ btnAbout Button
MoveScaled(39.875,45,15,4)
Text = ("&About")
Picture = Picture["graph.png"]
}
{ TextLabel1 TextLabel
MoveScaled(2,2,4,2.625)
Background = &HFFFFFF&
Text = ("(%)")
}
}
Hint: - Compiling from the command line.
- Navigate to your project folder ( the folder where all your .form, .class & .module files are located )
- Type the command gbc2 -a {full folder path}
- Type the command gba2 -o {full folder path}/myprojectname.gambas
- You will then have the myprogramname.gambas executable in the specified -o folder.