New to Gambas.. seek some help

New to Gambas? Post your questions here. No question is too silly or too simple.
Mudassir
Posts: 13
Joined: Monday 5th February 2024 11:10pm

New to Gambas.. seek some help

Post by Mudassir »

Hello, I am new to Gambas.. recently switched to Linux and trying to switch to some native platform for coding. Please assist a little. Thank you!

1. Which controls allow multi-column display of data (listbox / listview)?
2. How to make spinbox to accept decimal places?
3. How to configure valuebox to accept / not-accept decimal places?
4. How to set fixed (0, 2 or 3) decimal places in those controls?
5. Which database systems are supported?
User avatar
BruceSteers
Posts: 1578
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: New to Gambas.. seek some help

Post by BruceSteers »

Mudassir wrote: Monday 5th February 2024 11:18pm Hello, I am new to Gambas.. recently switched to Linux and trying to switch to some native platform for coding. Please assist a little. Thank you!

1. Which controls allow multi-column display of data (listbox / listview)?
2. How to make spinbox to accept decimal places?
3. How to configure valuebox to accept / not-accept decimal places?
4. How to set fixed (0, 2 or 3) decimal places in those controls?
5. Which database systems are supported?
1. Probably GridView is what you want.
https://gambaswiki.org/wiki/comp/gb.qt4/gridview

2. you cannot , spinbox is integer not float.
https://gambaswiki.org/wiki/comp/gb.qt4/spinbox

3. With valuebox set it's Type property to the format you want then setting the Value property should be automatic displayed.
https://gambaswiki.org/wiki/comp/gb.form/valuebox

4. no idea

5. gb.db info is specified here https://gambaswiki.org/wiki/comp/gb.db

Please have a good read of the gambas wiki https://gambaswiki.org/wiki
Most of the questions you have asked (except maybe number 4) have answers there in much more detail.
If at first you don't succeed , try doing something differently.
BruceS
User avatar
thatbruce
Posts: 168
Joined: Saturday 4th September 2021 11:29pm

Re: New to Gambas.. seek some help

Post by thatbruce »

The "usual" way to set the number of decimal points displayed in a control, whether it's a numeric or textual control is to use the Round() function when setting the value. This wont work for controls that only display or handle integers of course.
The "usual" way of doing a decimal spinbox is to multiply the value by 10^number of decimal points. This is a visual pain for the user but it's the best I could ever come up with.
b
Have you ever noticed that software is never advertised using the adjective "spreadable".
User avatar
thatbruce
Posts: 168
Joined: Saturday 4th September 2021 11:29pm

Re: New to Gambas.. seek some help

Post by thatbruce »

re database support. Gambas supports quite a lot of database handling (and it is incredibly fast) but the fully integrated database features are not (ahem) sophisticated. If you want to use more advanced SQL techniques almost anything can be done but you have to "do it yourself". For example, there is no direct way to call a postgres function you need to do an Exec call to the database. (I have no idea whether it could work for other database drivers as I wont touch MySql/MariaDB with a bargepole. Not because the Gambas interface doesn't work, just that MySQL and to a certain degree MariaDB doesn't bloody work IMO)
Have you ever noticed that software is never advertised using the adjective "spreadable".
vuott
Posts: 263
Joined: Wednesday 5th April 2017 6:07pm
Location: European Union

Re: New to Gambas.. seek some help

Post by vuott »

Mudassir wrote: Monday 5th February 2024 11:18pm 4. How to set fixed (0, 2 or 3) decimal places in those controls?
...:?...probably by using Format() function:
https://gambaswiki.org/wiki/lang/format
https://gambaswiki.org/wiki/cat/userformat
Europaeus sum !

Amare memorentes atque deflentes ad mortem silenter labimur.
Online
User avatar
cogier
Site Admin
Posts: 1127
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: New to Gambas.. seek some help

Post by cogier »

Welcome to the forum.
4. How to set fixed (0, 2 or 3) decimal places in those controls?
I agree with vuott regarding the number formatting, use Format. Run the following code in a Graphical application:-

TextBox1 As TextBox
Spring1 As Spring
Label1 As Label

Public Sub Form_Open()
  
  With Me
    .Arrangement = Arrange.Vertical
    .Padding = 5
    .W = 250
    .H = 100
  End With
  
  With TextBox1 = New TextBox(Me) As "TextBox1"
    .H = 28
    .Placeholder = "Enter any number below"
  End With
  
  Spring1 = New Spring(Me)
  
  With Label1 = New Label(Me) As "Label1"
    .H = 28
    .Alignment = Align.Center
    .Font.Bold = True
  End With
  
End

Public Sub TextBox1_Change()
  
  If Not IsNumber(Right(TextBox1.Text)) Then 
    TextBox1.Text = Left(TextBox1.Text, -1)
    Return
  Endif
  
  Label1.Text = Format(TextBox1.Text, "0,.00")  
  
End

1. Which controls allow multi-column display of data (listbox / listview)?
Here I agree with BruceSteers try GridView. Have a look at BarcodeCreator that's on the Gambas Software Farm.

Image
Mudassir
Posts: 13
Joined: Monday 5th February 2024 11:10pm

Re: New to Gambas.. seek some help

Post by Mudassir »

Thanks for responses. I wonder how active and dedicated you guys are (though the community is not so big.. but dedicated). I appreciate that.
@BruceSteers, @cogier many thanks for your response. Your dedication toward GAMBAS is appreciable. Wish you great luck!

About the queries:
1. Using Round() Function is a trick, not a solution.
2. Spin Box can accept decimal places (just a bit of work is required).
3. I seek support for largely used database systems (in the past too), not just SQLite. See, dBase,FoxPro, Visual FoxPro tables are still in use and people want to port them.
4. A Value Box is what I like most in GAMBAS controls but it need be capable to accept float values.
5. ListView control must also support multi-column data, I am sure (though I have not checked yet), there must be some confusion.
Mudassir
Posts: 13
Joined: Monday 5th February 2024 11:10pm

Re: New to Gambas.. seek some help

Post by Mudassir »

vuott wrote: Tuesday 6th February 2024 10:22am probably by using Format() function:
Sorry vuott, that's just a trick. It's about numeric input not formatted text.
Mudassir
Posts: 13
Joined: Monday 5th February 2024 11:10pm

Re: New to Gambas.. seek some help

Post by Mudassir »

BruceSteers wrote: Tuesday 6th February 2024 12:11am Q. How to configure valuebox to accept / not-accept decimal places?
3. With valuebox set it's Type property to the format you want then setting the Value property should be automatic displayed.
Well, IDK anything about GAMBAS and my VB skills are rusted as I'm primarily working with VFP for dekstop apps but still this may do the trick after setting type to number:
Public Sub valbox_Change()
  Dim myFra As String
  myfra = Str(Frac(valbox.value))
  ' Frac will return the number in digits like 0.xxxx
  ' Assuming to accept only 2 decimal places we would add 4 here two digits for 0. and two digits for decimal places
  ' Using round would round off the value like 2.256 would be 2.26
  If Len(myFra) > 4 Then
    valbox.Value = Int(valbox.Value) + Val(Left(myfra, 4))
  Endif
End

Or if there's a way to add property to controls at runtime then,
1. Add property decimal_places as Integer
2. control.decimal_places=2
and call control.decimal_places from above procedure, replacing 4 with 2+control.decimal_places

Also if only integer is required in Value Box input then:
Public Sub valbox_Change()
    valbox.Value = Int(valbox.Value)
End
User avatar
BruceSteers
Posts: 1578
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: New to Gambas.. seek some help

Post by BruceSteers »

I only know good tricks ;)

You will find all the gambas controls have their "default" behavior , to make them go beyond that you will need to employ some kind of "trick" or other.

With gambas there are many many tricks you can do to modify controls to work as you require.

Seems you have your own ideas on how it "should" be done so i do not think I have any advice except have fun experimenting :)
If at first you don't succeed , try doing something differently.
BruceS
Post Reply