New to Gambas.. seek some help

Post

Posted
Rating:
#1 (In Topic #1184)
Trainee
 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?
Online now: No Back to the top

Post

Posted
Rating:
#2
Guru
BruceSteers is in the usergroup ‘Guru’

Mudassir said

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.
/comp/gb.qt4/gridview - Gambas Documentation

2. you cannot , spinbox is integer not float.
/comp/gb.qt4/spinbox - Gambas Documentation

3. With valuebox set it's Type property to the format you want then setting the Value property should be automatic displayed.
/comp/gb.form/valuebox - Gambas Documentation

4. no idea

5. gb.db info is specified here  /comp/gb.db - Gambas Documentation

Please have a good read of the gambas wiki / - Gambas Documentation
Most of the questions you have asked (except maybe number 4) have answers there in much more detail.
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Regular
thatbruce is in the usergroup ‘Regular’
 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

Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Regular
thatbruce is in the usergroup ‘Regular’
 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)

Online now: No Back to the top

Post

Posted
Rating:
#5
Regular
vuott is in the usergroup ‘Regular’

Mudassir said

4. How to set fixed (0, 2 or 3) decimal places in those controls?
…:?…probably by using Format() function:
/lang/format - Gambas Documentation
/cat/userformat - Gambas Documentation

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#6
Avatar
Guru
cogier is in the usergroup ‘Guru’
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:-

Code (gambas)

  1. TextBox1 As TextBox
  2. Spring1 As Spring
  3. Label1 As Label
  4.  
  5. Public Sub Form_Open()
  6.  
  7.   With Me
  8.     .Arrangement = Arrange.Vertical
  9.     .Padding = 5
  10.     .W = 250
  11.     .H = 100
  12.  
  13.   With TextBox1 = New TextBox(Me) As "TextBox1"
  14.     .H = 28
  15.     .Placeholder = "Enter any number below"
  16.  
  17.   Spring1 = New Spring(Me)
  18.  
  19.   With Label1 = New Label(Me) As "Label1"
  20.     .H = 28
  21.     .Alignment = Align.Center
  22.     .Font.Bold = True
  23.  
  24.  
  25. Public Sub TextBox1_Change()
  26.  
  27.   If Not IsNumber(Right(TextBox1.Text)) Then
  28.     TextBox1.Text = Left(TextBox1.Text, -1)
  29.     Return
  30.  
  31.   Label1.Text = Format(TextBox1.Text, "0,.00")  
  32.  
  33.  

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.

<IMG src="https://www.cogier.com/gambas/Gridview3.png"> </IMG>
Online now: No Back to the top

Post

Posted
Rating:
#7
Trainee
 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.
Online now: No Back to the top

Post

Posted
Rating:
#8
Trainee

vuott said

probably by using Format() function:
Sorry vuott, that's just a trick. It's about numeric input not formatted text.
Online now: No Back to the top

Post

Posted
Rating:
#9
Trainee

BruceSteers said

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:

Code (gambas)

  1. Public Sub valbox_Change()
  2.   Dim myFra As String
  3.   myfra = Str(Frac(valbox.value))
  4.   ' Frac will return the number in digits like 0.xxxx
  5.   ' Assuming to accept only 2 decimal places we would add 4 here two digits for 0. and two digits for decimal places
  6.   ' Using round would round off the value like 2.256 would be 2.26
  7.   If Len(myFra) > 4 Then
  8.     valbox.Value = Int(valbox.Value) + Val(Left(myfra, 4))
  9.  
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:

Code (gambas)

  1. Public Sub valbox_Change()
  2.     valbox.Value = Int(valbox.Value)
  3.  
Online now: No Back to the top

Post

Posted
Rating:
#10
Guru
BruceSteers is in the usergroup ‘Guru’
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 :)
Online now: No Back to the top

Post

Posted
Rating:
#11
Trainee

BruceSteers said

I  only know good tricks ;)
:o
Would love to see those good tricks please.
That was just a quick solution I could think of with anything I could remember about 'basic'.
Online now: No Back to the top

Post

Posted
Rating:
#12
Regular
vuott is in the usergroup ‘Regular’

Mudassir said

that's just a trick. It's about numeric input not formatted text.
No… I didn't understand.

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#13
Trainee

vuott said

Mudassir said

that's just a trick. It's about numeric input not formatted text.
No… I didn't understand.
Sorry, let me explain… Suppose, I want to use Value Box to get user input for:
1. Rate of unit, there user should only enter value with 2 decimal places, not 3 or 4. like.. 2.25, not 2.258
2. Quantity (Decimal places depends on unit, like for units sold in pieces there would be no decimal places, for unit sold in meters there should be 2 decimal places and for units sold in kgs will have 3 decimal places. And we must not let user enter decimal value for pieces… there should not be 3 decimal places for units sold in meters. and likewise not 4 decimal places for units sold in kgs.

How to control user input when he/she is typing.. not on lost focus.
Online now: No Back to the top

Post

Posted
Rating:
#14
Guru
BruceSteers is in the usergroup ‘Guru’
There is a ValueBox_Change() event
There is a ValueBox_KeyPress() event

Processing can be done there.

Change happens after a user types something and if needs be you can modify the Value and change it.
KeyPress happens before the key is accepted by the control and if you Stop Event it will not enter the press.

Stop Event will stop an event working normally and override it's behaviour.

For example..

Code (gambas)

  1.  
  2. Public Sub ValuBox_KeyPress()
  3.  
  4.   If Str(Last.Value).Len = iMaxLen then
  5.     Stop Event  ' Stop the keypress event adding the char if the length is max
  6.     Return
  7.  
  8.  
  9.  

I'm not exactly sure what you're doing but you can intercept and stop many internal control events
Right click a control in the IDE and see the available events listed in the events menu.

It's not too hard to make your own valuebox with a textbox and use the KeyPress event to completely control it's display manually.
That's essentially all a ValueBox is.
Online now: No Back to the top

Post

Posted
Rating:
#15
Avatar
Enthusiast
GrayGhost is in the usergroup ‘Enthusiast’
This checks two different text boxs and only allows a number or editing key strokes, the two boxes are grouped together so one sub checks both boxes.

Code (gambas)

  1. Public Sub accountinfoBoxes_keypress()
  2.    
  3.    If Key.Code
  4.       If Last.Name = "TBankroute" Or Last.Name = "TBaccNum" And Not (IsDigit(Key.Text) Or
  5.          Key.Code = Key.BackSpace Or Key.Code = Key.Tab Or Key.Code = Key.BackTab Or
  6.         Key.Code = Key.Left Or Key.Code = Key.Right) Then Stop Event
  7.      
Online now: Yes Back to the top
1 guest and 0 members have just viewed this.