Page 1 of 2
Not the farm problem but mine Solved
Posted: Monday 7th June 2021 3:04pm
by grayghost4
I can not find the gambas farm
I am looking for code to convert a number to text for a check writing program
I have found excell macros and vb code ... there must be gambas code to do it also
Re: the farm is still down ??
Posted: Monday 7th June 2021 3:21pm
by cogier
There was an issue with Gambas.One accessing the Gambas Farm, so we are not doing it any more. You can access the Farm from Gambas: -
Re: the farm is still down ??
Posted: Monday 7th June 2021 3:58pm
by grayghost4
must be a dunce but I can't find the page you showed:
http://gambas.sourceforge.net
does not get me there ?
Re: the farm is still down ??
Posted: Monday 7th June 2021 4:59pm
by cogier
The page shown is what you see when you first open Gambas.
Re: the farm is still down ??
Posted: Monday 7th June 2021 6:14pm
by grayghost4
Like I said I am a DUNCE , I have been looking on line for a week for it
but there does not seem to be anything there that will help with my problem
Re: the farm is still down ??
Posted: Monday 7th June 2021 8:15pm
by BruceSteers
Theres also a menu item in the gambas ide takes you to farm
Re: the farm is still down ??
Posted: Monday 7th June 2021 8:17pm
by BruceSteers
If there is no solution available, make one
Or post the problem here...
Re: the farm is still down ??
Posted: Tuesday 8th June 2021 11:59am
by cogier
I am looking for code to convert a number to text for a check writing program
Run this code in a 'Graphical application'. It will display text up to 999.99. Hopefully it will get you started.
' Gambas class file
$Int As String
$Frac As String
HBox1 As HBox
HBox2 As HBox
Panel1 As Panel
ValueBoxInput As ValueBox
TextBoxAnswer As TextBox
Public Sub Form_Open()
If System.Language = "en_GB.UTF-8" Then
$Int = " pounds"
$Frac = " pence"
Endif
If System.Language = "en_US.UTF-8" Then
$Int = " dollars"
$Frac = " cents"
Endif
Me.Center
BuildForm
ValueBoxInput.SetFocus
End Sub
Public Sub ValueBoxInput_Change()
Dim iInt As Integer = Fix(ValueBoxInput.Value)
Dim iFrac As Integer = Int(Frac(ValueBoxInput.Value) * 100)
Dim sText As String
SText = GetText(iInt) ' Get the Pounds (Dollars)
TextBoxAnswer.Text = UCase(sText[0]) & Mid(sText, 2) & $Int
sText = GetText(iFrac) ' Get the Pence (Cents)
If Trim(sText) <> "" Then TextBoxAnswer.Text &= " and " & sText & $Frac
If ValueBoxInput.Value = 0 Then TextBoxAnswer.Clear
End
Public Sub GetText(iValue As Integer) As String
Dim sNumbers As String[][] = [["", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"], ["ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eightteen", "nineteen"], ["", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"]]
Dim sValue As String = Str(iValue)
Dim iLen As Integer = Len(sValue)
If iLen = 1 Then Return sNumbers[0][Val(sValue)]
If iLen = 2 And iValue < 20 Then Return sNumbers[1][Val(sValue[1])]
If iLen = 2 And iValue > 19 Then Return sNumbers[2][Val(sValue[0])] & " " & sNumbers[0][Val(sValue[1])]
If iLen = 3 And Val(Mid(sValue, 2)) < 10 Then Return sNumbers[0][Val(sValue[0])] & " hundred and " & sNumbers[0][Val(sValue[2])]
If iLen = 3 And Val(Mid(sValue, 2)) > 9 And Val(Mid(sValue, 2)) < 20 Then Return sNumbers[0][Val(sValue[0])] & " hundred and " & sNumbers[1][Val(sValue[2])]
If iLen = 3 And Val(Mid(sValue, 2)) > 19 Then Return sNumbers[0][Val(sValue[0])] & " hundred and " & sNumbers[2][Val(sValue[1])] & " " & sNumbers[0][Val(sValue[2])]
End
Public Sub BuildForm()
With Me
.Height = 100
.Width = 500
.Padding = 5
.Arrangement = Arrange.Vertical
.Center
End With
With HBox1 = New HBox(Me)
.H = 28
.W = 100
End With
With ValueBoxInput = New ValueBox(HBox1) As "ValueBoxInput"
.H = 28
.W = 160
.Type = ValueBox.Currency
End With
With Panel1 = New Panel(Me)
.H = 28
.W = 100
End With
With HBox2 = New HBox(Me)
.H = 28
.W = 100
End With
With TextBoxAnswer = New TextBox(HBox2) As "TextBoxAnswer"
.H = 28
.W = 100
.Expand = True
End With
End
Re: the farm is still down ??
Posted: Tuesday 8th June 2021 6:14pm
by grayghost4
Run this code in a 'Graphical application'. It will display text up to 999.99. Hopefully it will get you started.
thank you I was Halfway there ... but you have improved it greatly ... that is exactly what I was looking for
thanks again
Marv
Re: Not the farm problem but mine Solved
Posted: Friday 11th June 2021 10:48pm
by grayghost4
I went at the project a little differently than you did I wanted a max of 99999.99 all in one function..
I world be intrested in any comments or improvements
Thanks for the help.
Marv
Public Sub GetText(iValue As Float) As String
Dim sNumbers As String[][] = [["", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"], ["ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eightteen", "nineteen"], ["", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"]]
Dim sValue As String = Str(Fix(iValue))
Dim icents As Integer = Int(Frac(iValue) * 100)
Dim iLen As Integer = Len(sValue)
Dim sResult As String
Dim $ones As Integer = 0
Dim $teens As Integer = 1
Dim $over19 As Integer = 2
If iLen = 5 Then
If Val(Mid(sValue, 1, 2)) < 20 Then sResult = sNumbers[$teens][Val(Mid(sValue, 2, 1))]
If Val(Mid(sValue, 1, 2)) > 19 Then sResult = sNumbers[$over19][Val(Mid(sValue, 1, 1))] & " " & sNumbers[$ones][Val(Mid(sValue, 2, 1))]
sResult &= " thousand "
svalue = Right(svalue, 3)
iLen = 3
Endif
If iLen = 4 Then
sResult &= sNumbers[$ones][Val(Left(sValue, 1))] & " thousand "
svalue = Right(svalue, 3)
iLen = 3
Endif
If iLen = 3 And Val(Left(sValue, 1)) Then
sResult &= sNumbers[$ones][Val(Left(sValue, 1))] & " hundred "
svalue = Right(svalue, 2)
iLen = 2
Endif
If iLen = 2 Then
If Val(Right(sValue, 2)) < 20 Then sResult &= sNumbers[$teens][Val(Mid(sValue, 2, 1))]
If Val(Right(svalue, 2)) > 19 Then sResult &= sNumbers[$over19][Val(Mid(sValue, 1, 1))] & " " & sNumbers[$ones][Val(Mid(sValue, 2, 1))]
Endif
If iLen = 1 Then sResult &= sNumbers[$ones][Val(sValue)]
Return = "* * * " & UCase(sResult[0]) & Mid(sResult, 2) & " dollars and " & icents & " cents" & " * * *"
End