Hello, I represent a company developing software in Brazil.

I wonder why my program (VB6)
reading a number stored in the notepad, it reads
the decimal number.

for example if the value is stored 30.5
will display the value in textbox 305

how to make it understand the point.


Thanks

Edited 7 Years Ago by Domus BRASIL: n/a

I think you made mistake in declarations if any ..
Integers never load a decimal point.But a Double do.

Are you trying to open the notepad ??It is not clear .
Read from a notepad is equal to open it.Then you will get the whole data in notepad.

It may also depend upon your local settings on your computer. I don't know about brazil but some countries use the decimal/period character as a thousands seperator and since you have 30.5 and not 30.500 it may be stripping it.

So to perhaps solve this you may want to read the value into a string and then convert to a double.

Good Luck

I have several textbox to search a number that is in a line of a file in. txt

but if this number is decimal, it reads as if the number was over

what I do for a textbox recognize this number as a decimal?

So, you first read the value in from a text file, right? So at that point you have "30.5". Then somewhere it gets changed, right?

Dim SomeVariable As Double
SomeVariable = CDbl("30.5")

Good Luck

oi...
pelo que entendi vc esta com problemas de declaracao de variaveis como os outros colegas disseram. O maior problema e se vc esta conseguindo pegar o numero 3.5 , se afirmativo tente jogar numa string, apos trocar o ponto por virgula e entao joga-lo para double.

You can also try your textbox format -

Text1.text = Format(Text1.text, "### ###.##")
'Where ## is the actual number entered into text box.

You can also try this sub I've done some while back

Public Function Txtnumdeci(Key As Integer, Strinfo As String) As Integer
Dim Deciprs As Boolean
Dim Ctr As Integer
Dim Decipos As Integer

Decipos = InStr(Strinfo, ".")
If Decipos Then
    Deciprs = True
Else
    Deciprs = False
End If

Select Case Key
Case vbKey0 To vbKey9
    If Deciprs = True Then
        Ctr = Len(Mid(Strinfo, Decipos + 1, Len(Strinfo) - Decipos + 1))
        If Ctr = 2 Then
            Txtnumdeci = 0
        Else
            Txtnumdeci = Key
        End If
    Else
        Txtnumdeci = Key
    End If
Case vbKeyBack
    Txtnumdeci = Key
Case vbKeyDecimal, Asc(".")
    If Deciprs = True Then
        Txtnumdeci = 0
    Else
        Txtnumdeci = Key
    End If
Case vbKeyReturn
    SendKeys "{TAB}"
Case Else
    Txtnumdeci = 0
End Select
End Function

Hope this helps.

This article has been dead for over six months. Start a new discussion instead.