|
-
Jun 14th, 2007, 10:34 AM
#1
Thread Starter
Lively Member
[RESOLVED] String truncated when read via Line function
I am reading in a txt file that looks like this:
33QNATPAUTO1021-02,yes
33QNATPAUTO1018-02,yes
When I run my code, the first column is coming only as 33,which I don' understand why it is doing it that way. I really don't want to split this in an array b/c that increases the complexity of what I am trying to achieve.
Help???
Thanks,
Nadia
Here's my code:
Dim sFile
Dim claimnumber, flag As String
Dim fileNum As Integer
fileNum = FreeFile
sFile = "O:\5 Prj Mgmt\QA Sys\AutomationTestScripts\ClaimsGUI\Files\QNA\cl.txt"
'Opens the input file and reads in the values
Open sFile For Input As #fileNum
Do While Not EOF(1)
Input #fileNum, claimnumber, flag
Debug.Print claimnumber, flag
Loop
Close #fileNum
-
Jun 14th, 2007, 10:37 AM
#2
Addicted Member
Re: String truncated when read via Line function
Nadia -
- My suggestion is:
Code:
Dim sFile
Dim flag As String
dim strT as string
Dim fileNum As Integer
fileNum = FreeFile
sFile = "O:\5 Prj Mgmt\QA Sys\AutomationTestScripts\ClaimsGUI\Files\QNA\cl.txt"
'Opens the input file and reads in the values
Open sFile For Input As #fileNum
Do While Not EOF(#filenum)
Input #fileNum, flag, strT
Debug.Print flag, strT
Loop
Close #fileNum
Note that in your original code, claimnumber is not being DIMmed as a String, but is rather a Variant. My guess is that the code is attempting to parse the claimnumber as a value since the first character is numeric and stopping when it hits a non-numberic character (much the same as how the VAL function works).
Last edited by sigid; Jun 14th, 2007 at 10:50 AM.
-
Jun 14th, 2007, 11:01 AM
#3
Thread Starter
Lively Member
Re: String truncated when read via Line function
Thanks. I actually tried it earlier with a declaration as a string - but clearly I goofed somewhere along the way.
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
|