#1 (permalink)  
Old 03-25-04, 02:28 PM
daveyisu daveyisu is offline
New Member
 
Join Date: Mar 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
File input

Being used to VB6, the file input of VB.NET has got me very confused.

I have a file that is similar in form to this:

0.00 0.00 1.0564
1.00 0.00 0.023
0.00 1.00 0.0341
1.00 1.00 0.13453
0.00 2.00 1.236
1.00 2.00 0.0578

I need to input each of those numbers into a separate variable, all dimensioned as singles, ie.

Row = 0.00
Col = 0.00
Height = 1.0564

for the first line of data. In VB6 I could simply use the line

Input#1, row, col, height

but I have no idea how to do this in VB.NET.

I have read about the streamreader etc, but the best I've been able to come up with is a string that has all 3 values in it. I can't even read the file by byte size, because it can change.

Any help would be greatly appreciate.

Thanks

David
Reply With Quote
  #2 (permalink)  
Old 03-25-04, 04:08 PM
Shane Shane is offline
Coding Addict
 
Join Date: Jun 2003
Location: Maryland, US
Posts: 268
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by daveyisu
Being used to VB6, the file input of VB.NET has got me very confused.

I have a file that is similar in form to this:

0.00 0.00 1.0564
1.00 0.00 0.023
0.00 1.00 0.0341
1.00 1.00 0.13453
0.00 2.00 1.236
1.00 2.00 0.0578

I need to input each of those numbers into a separate variable, all dimensioned as singles, ie.

Row = 0.00
Col = 0.00
Height = 1.0564

for the first line of data. In VB6 I could simply use the line

Input#1, row, col, height

but I have no idea how to do this in VB.NET.

I have read about the streamreader etc, but the best I've been able to come up with is a string that has all 3 values in it. I can't even read the file by byte size, because it can change.

Any help would be greatly appreciate.

Thanks

David
Code:
Dim sr As StreamReader = New StreamReader("c:\TestFile.txt")
 
Dim line As String
 
Dim Row As Single
 
Dim Column As Single
 
Dim Height As Single
 
Dim line_array As String()
 
 
 
Do
 
line = sr.ReadLine()
 
If Not line IsNothing Then
 
line_array = line.Split(" ")
 
Row = Convert.ToSingle(line_array(0))
 
Column = Convert.ToSingle(line_array(1))
 
Height = Convert.ToSingle(line_array(2))
 
MessageBox.Show("Row is " & Row.ToString() & vbNewLine & "Column is " & Column.ToString() & vbNewLine & "Height is " & Height.ToString())
 
EndIf
 
Loop Until line Is Nothing
 
__________________
Shane Bauer
Microsoft Certified Professional (MCP) - ASP.NET
ASP/ASP.net, C#, VB/VB.NET, PHP, Perl, SQL
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with my largest perl script. Grabbing data from a file. Sunnmann Perl 2 04-23-08 03:27 AM
Getting the created file (fopen/fwrite) Programme PHP 5 02-14-04 03:09 PM
write to beginning of file or reverse an array of binary data abtimoteo Perl 1 01-20-04 10:09 AM
Please I Need help before all my hair is gone! LisatheNovice Perl 6 11-22-03 03:05 PM
Upload file type and size limiter! Arctic ASP 1 08-02-03 07:06 PM


All times are GMT -5. The time now is 02:20 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.