File Reading Function. Missing A Line
File Reading Function. Missing A Line
File Reading Function. Missing A Line
File Reading Function. Missing A Line
File Reading Function. Missing A Line
File Reading Function. Missing A Line File Reading Function. Missing A Line File Reading Function. Missing A Line File Reading Function. Missing A Line File Reading Function. Missing A Line File Reading Function. Missing A Line File Reading Function. Missing A Line File Reading Function. Missing A Line
File Reading Function. Missing A Line File Reading Function. Missing A Line
File Reading Function. Missing A Line
Go Back  Xtreme Visual Basic Talk > > > File Reading Function. Missing A Line


Reply
 
Thread Tools Display Modes
  #1  
Old 01-20-2005, 12:40 AM
Smdobay Smdobay is offline
Freshman
 
Join Date: Jun 2002
Posts: 25
Default File Reading Function. Missing A Line


So then. I'm attempting to create a function that is given two parameters and outputs a given text file response, much like an INI reader would.
Example:

Code:
GetDatLine("Astuff","Bstuff")

It would search through a file Looking Like:

[Astuff]
Bstuff=yadayada

It would then return:

"Bstuff=yadayada" as a string.

However, I'm missing the key, crucial component: The reading a line code.

Here's what I have so far:

Code:
Public Function GetDatLine(ByVal Section As String, ByVal Specific As String) As String Dim bTemp As Boolean Dim i& Microsoft.VisualBasic.FileOpen(1, AppPath() & "\file.dat", OpenMode.Input, OpenAccess.Read) While bTemp = False Or EOF(1) i = i + 1 'Insert Reading Line Here If GetDatLine = "[" & Specific & "]" Then Dim bTemp2 As Boolean While bTemp2 = False Or EOF(1) 'Insert Reading Line Here Too If Mid(GetDatLine, 1, 3) = Specific Then Microsoft.VisualBasic.FileClose(1) Exit Function End If End While bTemp = True End If End While Microsoft.VisualBasic.FileClose(1) End Function

Anyone know or can help?
__________________
There is an art to being a newbie; I pride myself on it.
Reply With Quote
  #2  
Old 01-20-2005, 08:23 AM
Iceplug's Avatar
IceplugFile Reading Function. Missing A Line Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

You know, you should be using the StreamReader instead of the slow backwards compatibility functions:
Add Imports System.IO to the top of your code window.

Dim SR As StreamReader = New StreamReader(AppPath() & "\file.dat")
instead of FileOpen.

SR.Close()
instead of FileClose.

SR.Peek = -1
instead of EOF.

SR.ReadLine()
instead of... well, you don't have that
So, SR.ReadLine() to read a line from the file.

Also, a few other things... bTemp is like Found to indicate if you found the key. (You could name it as such)
And, if so, why not set it to True in the place where you close the file and exit the function.
Don't forget to GetDatLine = yourstring
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #3  
Old 01-20-2005, 05:16 PM
Smdobay Smdobay is offline
Freshman
 
Join Date: Jun 2002
Posts: 25
Default

Thanks. I'll give that a shot.
__________________
There is an art to being a newbie; I pride myself on it.
Reply With Quote
Reply


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

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
File Reading Function. Missing A Line
File Reading Function. Missing A Line
File Reading Function. Missing A Line File Reading Function. Missing A Line
File Reading Function. Missing A Line
File Reading Function. Missing A Line
File Reading Function. Missing A Line File Reading Function. Missing A Line File Reading Function. Missing A Line File Reading Function. Missing A Line File Reading Function. Missing A Line File Reading Function. Missing A Line File Reading Function. Missing A Line
File Reading Function. Missing A Line
File Reading Function. Missing A Line
 
File Reading Function. Missing A Line
File Reading Function. Missing A Line
 
-->