Page 1 of 2
New to Gambas.. seek some help
Posted: Monday 5th February 2024 11:18pm
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?
Re: New to Gambas.. seek some help
Posted: Tuesday 6th February 2024 12:11am
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.
Re: New to Gambas.. seek some help
Posted: Tuesday 6th February 2024 7:03am
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
Re: New to Gambas.. seek some help
Posted: Tuesday 6th February 2024 7:11am
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)
Re: New to Gambas.. seek some help
Posted: Tuesday 6th February 2024 10:22am
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
Re: New to Gambas.. seek some help
Posted: Tuesday 6th February 2024 5:55pm
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.
Re: New to Gambas.. seek some help
Posted: Saturday 10th February 2024 7:32pm
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.
Re: New to Gambas.. seek some help
Posted: Saturday 10th February 2024 7:56pm
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.
Re: New to Gambas.. seek some help
Posted: Saturday 10th February 2024 9:16pm
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
Re: New to Gambas.. seek some help
Posted: Sunday 11th February 2024 12:58pm
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