|
-
May 12th, 2002, 12:57 AM
#1
Thread Starter
Junior Member
opening a file
i am opening a file with 5 lines
layed out in theis format
"string", "string", number, number
"string", "string", number, number
"string", "string", number, number
"string", "string", number, number
"string", "string", number, number
i only get the last line when i open it
so it says this
"string", "string", number number
this is my code any problems with this?
i have to rewrite to it also
Open "a:\THRFILE.DAT" For Input As #1
Do While Not EOF(1)
Input #1, name
Input #1, sex
Input #1, dba
Input #1, rest
Loop
Close #1
txtView.Text = name + " " + sex + " " + dba + " " + rest
-
May 12th, 2002, 01:02 AM
#2
Do While Not EOF(1)
Input #1, name
Input #1, sex
Input #1, dba
Input #1, rest
Loop
Close #1
From above, it's apparent that you're assigning the variables with the proper values, but you're not doing anything with them. So, once the file reaches it's EOF... it's the final values that you're presented with.
What are you trying to do with all 5 lines? 5 different textboxes? Plz elaborate
-
May 12th, 2002, 01:04 AM
#3
For one thing, you need to 'add' to the TextBox, like:
VB Code:
'Set txtView.MultiLine = True (at build)
txtView.Text = [b]txtView.Text[/b] + name + " " + sex + " " + dba + " " + rest + [b]vbCrLf[/b]
Place it in the Loop.
-
May 12th, 2002, 01:04 AM
#4
When you dim the name, sex, dba and rest
Instead of this:
Dim name ...
use this
Dim name() ...
Also, changer 'name' to something else like 'theName'
When you app starts, Dim all the vars with zero elements like this:
ReDim theName(0)
ReDim sex(0)
ReDim dba(0)
reDim rest(0)
Finally, Change this:
Do While Not EOF(1)
Input #1, name
Input #1, sex
Input #1, dba
Input #1, rest
Loop
To This:
Do While Not EOF(1)
reDim preserve thename(0 to UBound(name) + 1)
reDim preserve sex(0 to UBound(name) + 1)
reDim preserve dba(0 to UBound(name) + 1)
reDim preserve rest(0 to UBound(name) + 1)
Input #1, name(ubound(name))
Input #1, sex(ubound(sex))
Input #1, dba(ubound(dba))
Input #1, rest(ubound(rest))
Loop
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
-
May 12th, 2002, 01:06 AM
#5
Then, to show in a text box:
txtView.text = ""
For LoopVar = LBound(name)+1 to UBound(name)
txtView.Text = textview.text & name(loopvar) & " " & sex(loopvar) & " " & dba(loopvar) & " " & rest(loopvar) & vbcrlf
Next
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
-
May 12th, 2002, 01:10 AM
#6
Hey Bruce, what app is that in your sig?
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
-
May 12th, 2002, 01:18 AM
#7
Also, u can load multi-variables on the one line like:
VB Code:
Do While Not EOF(1)
Input #1, name, sex, dba, rest
txtView.Text = txtView.Text + name + " " + sex + " " + dba + " " + rest + vbCrLf
Loop
Close #1
Lord_Rat: Thats my Intel(R) Active Monitor app that came on the CD
for the MotherBoard. Nice little app too - monitors Temps, Power etc 
Bruce.
-
May 12th, 2002, 01:21 AM
#8
Looked it up and it's specific to Intel boards. Oh well.
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
-
May 12th, 2002, 01:25 AM
#9
Theres probably heaps of freeware stuff like that out there.
Anyways, I guess u could knock something similar up in VB
-
May 12th, 2002, 11:56 AM
#10
Thread Starter
Junior Member
ok i have it all in a subprocedure and it opens now thanks
but i have to perform a calculation on dba and rest
it s giving me a type mismatch error
txtView.Text = txtView.Text + name + " " + sex + " " + dba + " " + rest + vbCrLf
I dimmed it the same where it is called so Im a little lost
Private Sub Spot(name As String, sex As String, dba As Integer, rest As Integer)
txtView.Text = ""
txtView.Enabled = True
Open "a:\THRFILE.DAT" For Input As #1
Do While Not EOF(1)
Input #1, name
Input #1, sex
Input #1, dba
Input #1, rest
txtView.Text = txtView.Text + name + " " + sex + " " + dba + " " + rest + vbCrLf
Loop
Close #1
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
|