Pear Linux tutorial, tips and how to

 
Showing posts with label Gambas Tutorial. Show all posts
Showing posts with label Gambas Tutorial. Show all posts

How to get system host name using Gambas

Hi see you again in Gambas 3 tutorial. On this tutorial, I want to share how to get the system host name using Gambas. The idea of this program is to display a text displaying the system host and architecture when a button is clicked. 

The code are as follow:

 

Public Sub Form_Open()

btn_hostname.Text = "System Hostname"

Me.Center

Label1.Text = ""

Label2.Text = ""

End

 

Public Sub btn_hostname_Click()

   Label1.Text = "My system host name is :" & system.Host           =====get the system host name and displayed in Label1

   Label2.Text = "My Operating System is :" & system.Family & " -" & system.Architecture  =====get the system family and architecture in Label 2

End

 

Public Sub btn_exit_Click()

  Me.Close

End

Gambas Tutorial - Center the form on startup

Hi, see you again on Gambas tutorial. This time we'll continue to learn about Gambas programming. On the previous post, I've written how to create new project and create our first Hello World application. Now I want to show you how to make the form position in the center of the screen everytime we launch our application. By default, Gambas will display the form on the top left of the screen and I think its important to move it to the center on startup. 

Here is the clue. Find the section Public Sub Form_Open() on the FMain class. Me.Center code will move the form to the center of the screen everytime the form is opened. 

Public Sub Form_Open()

Me.Title = "First Exercise"

Me.Center

End

Here is the result

Gambas Exercise - Hello World

Hi, see you again on my blog. I hope you enjoy it. On this occassion I want to share about Gambas programming. I've posted how to install Gambas 3 on Pear OS 8 and now I want to learn how to coding with Gambas 3. OK I want to start to create a Hello World. My program will display "Hello World" text when the button is clicked. 

First, Open Gambas and go to Project | New Project. 

Select Graphical application on the left and press Next to continue. Now select the project parent directory, where you want to save the project. 

Next, provide the project title and project name. 

Press OK and now your project is ready. We can start designing and coding. On the Gambas 3 main window, double click FMain on the left to see the design form where we put button, etc. 

Click Button from the Form tool and now draw the button on the Main Form by dragging your mouse. See my example:

Double click Button1 to see and start coding

Public Sub Button1_Click()

  message("Hellow World")

End

Now, Compile the project. Use F7 or go to Project | Compile. Now run the program and Viola

Daily Categories