Post by carlos45 on Mar 19, 2024 23:08:59 GMT
Dear Bplus,
I am facing a problem with QBasic 64 and would like to ask again for your help in resolving it. I'm trying to use the FormatarSaldo function to format a balance represented as _INTEGER64 in a formatted string. However, I'm getting an error when trying to define the function.
Function FormatarBalance(balance As _INTEGER64) As String
QBasic is returning an "EXPECTED" error when trying to define the function this way.
I'm just starting to work with sub and I'm having difficulty solving this problem. The purpose of the code is to allow the user to enter numbers without dots and then format them so that they have dots to separate the units from thousands.
If you can help me understand why I'm getting this error and how I can fix it, it would be greatly appreciated again.
Thanks in advance for your help!
Carlos
I am facing a problem with QBasic 64 and would like to ask again for your help in resolving it. I'm trying to use the FormatarSaldo function to format a balance represented as _INTEGER64 in a formatted string. However, I'm getting an error when trying to define the function.
Function FormatarBalance(balance As _INTEGER64) As String
QBasic is returning an "EXPECTED" error when trying to define the function this way.
I'm just starting to work with sub and I'm having difficulty solving this problem. The purpose of the code is to allow the user to enter numbers without dots and then format them so that they have dots to separate the units from thousands.
If you can help me understand why I'm getting this error and how I can fix it, it would be greatly appreciated again.
Thanks in advance for your help!
Carlos
DIM saldo_inicial AS _INTEGER64
DIM saldo_final AS _INTEGER64
Input "Insira o saldo inicial: ", saldo_inicial
Input "Insira o saldo final: ", saldo_final
Color 31: Locate 14, 3
Print "O saldo inicial era de R$ "; FormatarSaldo(saldo_inicial)
Color 31: Locate 16, 3
Print "O saldo final ‚ de R$ "; FormatarSaldo(saldo_final)
Function FormatarSaldo(saldo As _INTEGER64) As String
Dim saldo_com_pontos As String
saldo_com_pontos = LTrim$(Str$(saldo))
Dim length As Integer
length = Len(saldo_com_pontos)
Dim i As Integer
For i = length - 3 To 1 Step -3
saldo_com_pontos = Left$(saldo_com_pontos, i) + "." + Mid$(saldo_com_pontos, i + 1)
Next i
FormatarSaldo = saldo_com_pontos
End Function