-
June 3rd, 2010, 11:58 AM
#1
Problem with reading txt file
Hi.
i have a problem when I read from a txt file.
I looks something like this:
Spa
1,216
1,081
And now when I put the data into strings, the values are:
Spa
1
216
Why does it stop at the " , " ?
I don't wan't it to stop at the ","
-
June 3rd, 2010, 01:02 PM
#2
Re: Problem with reading txt file
Because , is a field-delimiter in VB6, not a decimal separator.
-
June 3rd, 2010, 01:10 PM
#3
Re: Problem with reading txt file
Ok, but I have now solved the problem, I changed , to .
But there is a new problem now, if the number is below 1 ex: 0.9
Then it only shows 9.
How do I solve this problem?
-
June 3rd, 2010, 01:55 PM
#4
Re: Problem with reading txt file
We're not mind readers... if you post the code you are using we may be able to help.
-tg
-
June 3rd, 2010, 02:32 PM
#5
Re: Problem with reading txt file
instead of using input to get the data use line input that will read the entire line and not break at the comma
Always use [code][/code] tags when posting code.
-
June 4th, 2010, 07:13 AM
#6
Re: Problem with reading txt file
Hi,
I don't know how you are reading text file.
But try this one.
<Code>
Option Explicit
Private Sub Form_Load()
Call ReadFormFile("C:\Test.txt")
End Sub
Rem Read data from file using Sequentila file handling
Public Function ReadFormFile(strFilePath As String) As Boolean
Dim tempString As String
Rem Open text file
Open strFilePath For Input As #1
Rem Read line by line
While EOF(1) = 0
Line Input #1, tempString
MsgBox tempString
Wend
Rem Close text file
Close #1
End Function
</Code>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|