Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




How To Read File


right I'm abit lost cause I dont know how to read into a file

if supposing I was to write or append into a file I would use something like

Open File For Binary As #1
put me,1.txt
close #1

But what if I want to read the data in a file how do I do it,casue in pascal I used to use fseek but I dont know how to read in vb, how?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Read An Excel Spreadsheet Column, That Is, Read From The Top Cell To Bottom Cell (like File R
How to read an excel spreadsheet column, that is, read from the top cell to bottom cell (like file read to eof)? how can I know which cell is the last cell?

thanks

How To Read MS Word File To RTB And Edit It And Save It Or How To READ MS Word? The Rtb Control Does
How to read MS Word file to RTB and edit it and save it Or how to READ MS Word only? The rtb control doesn't seem to work. I am using VB 6.

File Exists?? Read File Data, Read New File Data, Put Together....
Hi... i'm a newbie to VB and i just wonder....

i've made a program which opens file's (*.*) and its data (comma separated).

The file's are named like this: DUTW1234^28_02_2001.*
DUTW1234 is a computer's name
^ separate's the computername and the date the file was created.
28_02_2001 is the date the file was created.


A file for example:

Winnt Explorer,1
Notepad,43
Ansys,2
Microsoft Outlook, 5
Netscape,23
Winnt Explorer,4
Notepad,4
Ansys,24
Microsoft Outlook,0
Netscape,46
Winnt Explorer,13
Notepad,0
Ansys,16
Microsoft Outlook,2
Netscape,8


You can see, the applications are named several times. This program i wrote looks which applications are named and counts the numbers. Then it write's the information to a *.csv file. In Microsoft Excel it looks like this:

| columm A | columm B |
--------------------------------------------
1 | Winnt Explorer | 8 |
2 | Notepad | 47 |
3 | Ansys | 42 |
4 | Microsoft Outl | 7 |
5 | Netscape | 77 |

Here's the code:

Type PROG_DATA
Title As String
Count As Integer
End Type


Public Sub Main()

Dim eProgData(100) As PROG_DATA
Dim sTitle As String
Dim sTemp As String
Dim sNumber As String
Dim iFree As Integer
Dim bFound As Boolean
Dim lK As Long

folder = "c: est"
bestand = Dir(folder & "*.*")

Do While bestand <> ""

'emtpy array
For lK = 0 To UBound(eProgData)
eProgData(lK).Count = 0
Next lK

'Read file
iFree = FreeFile()
Open folder & bestand For Input As #iFree
Do Until EOF(iFree)
Line Input #iFree, sTemp
sNumber = Right(sTemp, Len(sTemp) - InStr(1, sTemp, ",") - 1)
sTitle = Left(sTemp, InStr(1, sTemp, ",") - 1)
bFound = False

'Checks if file exsists
For lK = 0 To UBound(eProgData)
If eProgData(lK).Title = sTitle Then
eProgData(lK).Count = eProgData(lK).Count + sNumber
bFound = True
Exit For
End If
Next lK

'Check if found
If bFound = False Then
'Maak nieuw programma aan
Icount = Icount + 1
eProgData(Icount).Title = sTitle
eProgData(Icount).Count = sNumber
End If

Loop
Close #iFree

iFree = FreeFile()

'write results
Open folder & "output" & bestand & ".csv" For Output As #iFree
For lK = 1 To Icount
Print #iFree, eProgData(lK).Title & ", " & eProgData(lK).Count
Next lK

Close #iFree
Kill (folder & bestand)
bestand = Dir
Loop
End Sub


If i run the program twice the file who was created the first time is overwritten by the second.
Now i want to know how i can check if the DUTW1234^28_02_2001.csv for a DUTW1234^28_02_2001.* file already exsists.
If this file already exsists then i want to open both file's and put the data together.

Anyone who knows a solution???

Path/File Access Error. Unable To Read Or Write The Specified File
Hi,


I am getting the following error

"Path/File Access Error. Unable to Read or write the specified file.

Unable to Display the Image"


Following is the Code i am using .
With ImgEdit1
.Image = gStrFilePath & "" & pImagefile
.Page = 1
.Display
.FitTo 1
End With


The OS is windows 2000 and i am using ImageEdit control

the variable gStrFilePath contains the Path of the file
PImagefile contains the Image Name . Image is Tiff image.


If i click OK on the error messages the application closes. If i run the application again i am able to display the same Image.


Pls Help me

Using ADO Recordset, Read From An Access Database File And Write To A Text File
Using the ADO data control and the recordset property I am reading records from an Access data base file, selecting and manipulating records, and then trying to write to a text file. I know how to get the records from the database file, but I need sample code for how to write out to a text file.
Thanks

cruella69

Read Chinese From Text File - Input Past End Of File
I have a text file with content of Chinese character which is store as ANSI format. When i call the function below, it give me error "Run-Time Error '62'. Input past end of file".

sFileName3 = "abc.txt"
sFilePath = sParentPath & sFileName3
Open sFilePath For Input As #1
sBasicDesc = Input(LOF(1), #1)
Close #1

I tested on 9 PC but 2 PC fail.
Do i miss out any component or the code is not compatible?
Please help.
Thankyou.

How To Read A Text File That Conatains Asp Code Into An Another Asp File And Execute?
Hi,
I just want to know if there is something like the eval() function in ASP ........... I want to read a asp page into another as page using FSO .... and execute it .....

this is the code i now use


Code:
on error resume next

sPage = Request.QueryString("url")

Set filesys = CreateObject("Scripting.FileSystemObject")
path = server.MapPath(sPage)
Set filetxt = filesys.OpenTextFile(path, 1, True)
tl = filetxt.ReadAll
filetxt.Close

if len(tl) < 1 then
Response.write("File Not Found !")
End if

response.Write(tl)


now when I read a asp page using this code the page includes and the asp codes are not executed ........

How can I read and excute a ASP file .......

http://www.weareequal.org/goto_text.asp?url=Home

Regards,
Dasith

How To Read Data From A File When The File Has 2 Byte Characters (UNICODE)?????
Hi!
I want to read data from a file in which data is written in 2-byte characters (unicode). Actually i want to make a control that reads data from a file and writes the corresponding integer value (2-byte) to another file. This is easy in Visual C++ environment but in VB i am stuck. please help. I have very little time left to complete the task.

thanks in advance

[VB6] Read In A File Delete Text And Write File
I have a tab delimited text file that I need to read in, remove text up to and including the first CR/LF and then write the remaining text back out to a file.

In the example file below, the first CR/LF is after 20080513 (although that number could be different). The file always starts with the word "Report". As an example, what I need to do in the file below is read the file in, remove the first line up to and including the CR/LF (which in the case below is Report Executed at Mon May 14 20:28:24 CDT 2007 for dates between 20070315 and 20080513 ) and then write the remainder of the file back out to another file.


Here is an example of the tab delimited file: (sample.txt)

Report Executed at Mon May 14 20:28:24 CDT 2007 for dates between 20070315 and 20080513
WRIDTTNASGN GROUPWCOOSJOBTYPETZCOMM_DTTMRPT_DTTMLOAD_START_DTTMLOAD_END_DTTMSOURCESTATUSBUCKET
5036884471089GA_Atl_NORTHEAST_D404295MRDLCTEASTERN20070316 23:5920070316 09:2420070316 00:0120070316 00:01LMOSPENDINGNONDEMAND
50398881236676GA_W_ROME_NEWNAN_PC770408MRMIFTEASTERN20070319 23:5920070319 04:5620070319 00:0120070319 00:01LMOSPENDINGNONDEMAND
50398885236800GA_W_ROME_NEWNAN_PC770400MBCTRTEASTERN20070319 23:5920070319 04:5720070319 00:0120070319 00:01LMOSPENDINGNONDEMAND
50398886236831GA_W_ROME_NEWNAN_PC770400MBCTRTEASTERN20070319 23:5920070319 04:5720070319 00:0120070319 00:01LMOSPENDINGNONDEMAND
50422929261569GA_W_ROME_NEWNAN_PC770400MRMIFTEASTERN20070320 23:5920070320 04:5120070320 00:0120070320 00:01LMOSPENDINGNONDEMAND
50489568333675GA_W_ROME_NEWNAN_PC770400MBCTRTEASTERN20070323 23:5920070323 04:5620070323 00:0120070323 00:01LMOSASSIGNNONDEMAND

Thanks in advance for your help...

How Can I Read A Ms-word File Without Opeing A File ????(urgent)
I ahve to create Tree view strutre .then when ever ia m cliking i *.Doc i ahve to display the MS-word file .up to that i had done .in next box .immdetly i have disply(after clicking *.Doc)
ie
one .Doc character s?? exaple 2500
two.doc cahracaters??
three.doc etc
but ia m able to do with TXT format how about MSword file .here i am sending TXt fiel to reading using LINEINPUT.
please dounload code in C : drive
anticipation
thanx

Read String From File And Save It To Another File With Change
Private Sub Command1_Click()



Dim FileNum As Long
Dim line1, line2, line3, strfind As String
Dim i As Integer

strfind = "pagebreak"
I am trying to read a string and look for the word "pagebreak" and write the string to a new file repacing the pagebreak with vb newline. I need my new text file to have new pages every time I read the pagebreak string. The following code work, but copy the code to a new file without starting a new page.

Thanks

strfind = "pagebreak"
FileNum = FreeFile
Open "c: est.dat" For Input As #FileNum
Do Until EOF(FileNum)
Input #FileNum, line2
line1 = line1 + line2

i = i + 1
line3 = ReplaceFirstInstance(line1, strfind, NewPage)
Loop




End Sub

Function ReplaceFirstInstance(textbody, searchfor, startover)
FoundLoc = InStr(1, textbody, searchfor)
If FoundLoc <> 0 Then

Open "C: est2.txt" For Output As #2
Print #2, textbody & NewPage

Close #2
Else
ReplaceFirstInstance = SourceString
End If
End Function

Picture File Problem / Binary File Read
Could someone help me with this code?

[code]
        SavePicture picTemp.Image, App.Path & " mpout.bmp"
        DoEvents
        Open App.Path & " mpout.bmp" For Binary Access Read As #7
            Do While Not EOF(7)
                Get #7, , sFileDataTemp
                sFileDataOut = sFileDataOut & sFileDataTemp
            Loop
            lFileLen = Len(sFileDataOut)
        Close #7
[code]

What's happening is, the "Get #7, , sFileDataTemp" line is not returning any data, when I step through my code, it show's sFileDataTemp = "".  I've created a temp program that does just the above, and it seems to work fine.  All the variables are Dim'd as local strings, except for lFileLen which is a local Long.

I've also verified that the save portion is correct, it generates a bitmap that I can open with any editor just fine.

Thanks

Read File, Transform And Write New File. RESOLVED
Hi,
  I'm trying to read the contents of a text file, cut out a few charachters and write to a new file. The file I'm reading looks like this
#1899-12-30 15:42:14#,3
#1899-12-30 15:42:16#,1
#1899-12-30 15:42:18#,1
 the reading part isnt a problem but i only want to write the time stamp and the number at the end of the line (which is always either 1 or 3) into the new file. Is this possible just using the mid() or Right() functions? The new file is going to be used to calculate the differences between the timestamps. Any help would be greatly appreciated. I just cant seem to get my head around this.
Thanks.



Edited by - confuzedone on 4/24/2006 3:19:25 AM

How To Read Binary File And Export To Text File ??
how to read binary file and export to text file ??
thanks very much !

How To Read From Text File And Append It To Excel File
could somebody pls help to read from a text file
and append the content to excel file.
the text file format is like this:

abs,123
aaann,89
1111,ybk

and i want to append it to excel file

col1 col2
abs 123
aaann 89
1111 ybk

please help

To Read A File Using File System Object
i have a file which has the following contents.

********************************
<filename:myfile.txt>
contents:
<details>
<name>xyz</name>
<std>plus2</std>
abc school
</details>

Note:there is no tag for the lastline
**********************************

Now i want to read this file and need the output as follows in excel

name std
xyz plus2 abc school

Read Text File And Write To Another File
The original file format is like that:

Header
2.85667000
99.70000000
4.01666940
101.46667000
2
Decimal
1.01.33
Some description
EndHeader
START 43, L, 174=0;133=300000
100.81888000 3.85663000
100.81778000 3.85625000
100.80883000 3.85519000
STOP
START 43, L, 174=2;133=300000
101.29401000 3.20013000
101.29359000 3.20232000
101.29134000 3.20748000
STOP

i need to change it to another kind of format as below and save as another file by using visual basic 6.

2.85667000
99.70000000
4.01666940
101.46667000
Decimal
100.81888000 3.85663000 174=0
100.81778000 3.85625000 174=0
100.80883000 3.85519000 174=0
101.29401000 3.20013000 174=2
101.29359000 3.20232000 174=2
101.29134000 3.20748000 174=2

How Can I Read From A TXT File Or INI File And Parcing In Dialogue Box
Hi guys

I am looking to find out, how can I read from a local INI file or TXT and parce the information in a Dialogue box. using VB 6


Any Help is appreciated

thanks

Open File For Combo File Read
Ok for some reason today is not my day to code.

I am trying to get my combo box to read data from my txt file.

I am not getting any errors I am just not getting any info.


VB Code:
Private Sub form1_load()Dim cabin As StringOpen "Cabin Names.txt" For Input As #1Index = 0Input #1, cabinname Combo1.AddItem cabinname Close #1 End Sub


Thanks for your help

Read A File In A Folder With File Name Given By User?
Hi,

I have a set of files in a folder.I want to read a file in that folder,where the file name is given by the user at runtime.How to get filename from user and how to read that corresponding file from the folder.
If anyone know how to do it.Please let me know.
Thanks in Advance,
Regards,
Nagarajan

How To Read Excel File As Text File
i want to read excel file as text file. then after doing some changes i want to store it in new excel file.
the code is
Dim y As TextStream
Set y = Fs.OpenTextFile("c:xxx.xls")
Text1 = y.ReadAll
y.Close

Text1 = Replace(Text1, "Webpage", "mywebpage")

Set y = Fs.CreateTextFile("c:xyz.xls")
y.Write Text1
y.Close

but its creating some problem.
pls check it.
thanx

How To Read Jar File And Serialized File
hi everybody

i have a jar file which contains images and a serialized file which i create using java.now i want to know whether i can read the jar file and the serialized file using visual basic.plz send me the code for the same if it is possible

thanks

Can You Read A Text File From A Zip File...
Hi,

I have a vb app which gets a lot of it's configuration information from several text files. The info. is stored in the text files text delimeted style i.e. "some data", "some more data", "etc..."

What I would like to do is stop users from opening these text files and changing the data in them.

I thought about zipping up all the text files together in a password protected zip file and then getting my vb app to read the text file from the zip file, thus stopping most users from being able to change the data in the text files.

Is this possible???? and if so, can anyone tell me how to do it, please????

Thanks in advance,

Xan

Can A PDF File B Read Like Text File?
Gidday...

Can i pasre a pdf file for reading the same as i open a .txt file?

---------------------------------------------------------------------------------------------------------------------------------
Todays random quote: I am still determined to be cheerful and happy, in whatever situation I may be; for I have also learned from experience that the greater part of our happiness or misery depends upon our dispositions, and not upon our circumstances.

Martha Washington (1732 - 1802)
---------------------------------------------------------------------------------------------------------------------------------

Read Me File Using P&&dw
I want to add an read me file before my program is installed on a person's computer using the package and deployment wizard. does any one know how to do this or were their is documentation on customizing the package and deployment wizard?

Read From File
Great. Now, suppose you want to read from the file you have saved in Append one line at a time, how would you proceed?

Let's say we have a textbox (Text1) and a command button (Command1). When the user first clicks on Command1 he should be able to see the content of the first line in the textbox. When he clicks the second time he should retrieve the second line etc.

Can anybody translate it into code?

TIA


Quote:





Originally Posted by Iceplug


Open the file For Append.

Open filename For Append As #1
Print #1, "Line at the end of the file.
Close #1
.

Read File
How can i search and read i file which is search from drive list box, directory list box and file list box. Instead of hard code it like this?


Code:
Open "c:\MC2003120500800100940.dat" For Input As #1

File Read
I want a text file to have the text:

C:Blahlahal.wav

in it.

Then I want to be able to read this text and put it into a variable, but I have no idea how!

Read .doc File
Okay - I am an idiot - why can't I open a doc file like a txt file and read it - all I get is junk. PLEASE HELP

And - is there also a nice quick and dirty way to rename a doc file as a txt file?

Phil

How To Read File
how to read a unicode and a unicode(utf 8) file in visual basic
what is the different between the two files

Read From *.txt File
I want to read from a textfile (ASCII) which contains some lines with data from some bankmutations. Each line contains the same configutation.

1. line first 10 characters contains banknumber
1. line character 11 till 15 contains date
1. line character 16 till 25 contains description
etc.
etc.

Then 2. line contains same data, on same place.....

I want to open this file (Filename D:mut.asc.txt) and read this data into some textboxes. Further steps I already know (want to save this data in a Access Database).

I can't read the data out of this txt-file.... Please HELP!!!!

Thank you very much for your co-operation!!!

Read File After A EOF
i want to read the subject of a PDF file. That is easy. But if the files is securised, they have a EOF in the middle of the PDF. how i can pass the EOF for finish to read the PDF ???

sorry my code is in french, but is really not very hard to understand

Const sujet = "/SUBJECT"

Public Function getDescriptionPDF(strFile As String) As String

Dim texte As String
Dim trouver As Boolean
Dim position As Integer
Dim texte2 As String

If InStr(Mid(strFile, 2), "*") <> 0 Then
strFile = Mid(strFile, InStr(Mid(strFile, 2), "*") + 2)
End If
'On Error GoTo Fin

trouver = False

Open strFile For Input As #1

While Not trouver And Not LOF(1)
Input #1, texte
position = InStr(1, UCase(texte), sujet)
If position <> 0 Then
trouver = True
getDescriptionPDF = Mid(texte, 11, Len(texte) - 11)
End If
texte2 = texte
Wend
Close #1
End Function

Read A File From The Web ?
Hi people,
I know how to open files stored on my computer:
Open "C:whatever" for Input as #1 ... blah blah blah

I was wondering if you could do the same with files stord on the net:
Open "mydomain.com/mypath/myfile.txt" for Input as #1
(yes, i know this won't work like that, but that sort of idea)

And if this file is password - protected (yes, this is part of my website, and i have the password for it) is there a way that i can send the username and password as well ?

Thanks for your help

Read File
i want to make the most simple thing of the world for all of you, but not for me.. i want to read a file char by char can you help me?

Read File
I want to open a simple text file, read each line of it ans show it in a msgbox.
The number of lines are not specified.
How?

Read From A .TXT File
Hi,

I Have a .txt with 1000 Lines.
Is there any way Every Time I hit a Command button it gets one of the lines
Puts it in Text1
Deletes that line from the .txt file
and saves the file?

Ex:
My Text File has
abc
def
ghi

I Want it so when I hit the command button, it selects one of those, put's it in text1.text
Deletes it from my .txt then saves it.
Thanks

Edit: If that's too much, then something that just copies one line into text1.text

It Dosn't have to delete it.
Chance of selecting the same out of a few thousand is not..too often.

Read File On LAN
I need my program to read from a file that is on another computer in a LAN. The file is not necessarily being shared. If this isn't possible, can I get the program to share the file to read it then unshare it again?

Read A Txt File In VB
Good morning.

I must read this txt file:
|Mary|Jo
b1|5000|
|John|Job2|2000|

I don't know how we read a txt file in VB.

When I find the enter I will done it like this:

|Frosso|Job1|5000|
|John|Job2|2000|

I want the enters in the end of the line but nowhere else.
When the txt has the format that I want i overwrite it.
Can everyone help me? It is very important for me.

Friendly
fgk

To Read Any Xml File
Hello.
I need to read xml files with visual basic and I have found some utilities, but I couldnt read files with especial characteristics.

For example

<Conceptos>
<Concepto cantidad="12" descripcion="Jeans Levis " importe="3938.76" valorUnitario="328.23">
</Concepto>
<Concepto cantidad="16" descripcion="Charlize pant" importe="4350.08" valorUnitario="271.88">
</Concepto>
</Conceptos>

I need to get the information of Concepto
I need to get the values 12,Jean Levis,3938.36, etc, etc.
Where I can find an utility that can do this?

If the information is simple like this
<Concepto>cantidad3</Concepto>
I dont have problem, I get cantidad3, but if is like this
<Concepto cantidad ="cinco">
</Concepto>
I have problem, I cant get cinco
However the explorer can read both examples

Read From A File?
if i have a file with content like this :

Code:
BL:nameC008000
BL:xN007001
BL:yN007001
STR01C050000
STR02C050000
STR03C050000
STR04C050000
XXXX<tab><tab>???????
how can i read all the strings before the tabs? (BL:name, BL:x, BL:y, STR01, etc.)

thx

Cannot Read Dbf File
Hi I am still new in these forum.. i need your experties.. If your can solve my problem.. you are really great programmer..

I use activeX data object and listview and common dialog to read the data from file and list it in the listview.

I can access the dbf data in c:projectdata.
But When I try to access dbf data in c:projectdataall prot..I got the error. I think the error because my data folder rename have a empty space. How I can read the data with have space in the data folder




HTML Code:
Dim cnn As New ADODB.Connection
Dim dbf_name As String
Dim dbf_path As String
Dim rs As New ADODB.Recordset
Dim fld As ADODB.Field
Dim colHeader As ColumnHeader
Dim itemX As ListItem



Dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
Dim CurrentFolder: Set CurrentFolder = fso.GetFolder("c:projectdata")

Dim Files: Set Files = CurrentFolder.Files

Dim File
For Each File In Files

Dim strfilename As String
Dim resultString As String

strfilename = File.Name
If InStr(1, strfilename, " ") > 0 Then
resultString = Replace(strfilename, " ", " ")
If (extOld <> "" And extNew <> "") Then
StdOut.Echo Replace(Replace(File.Path, oldTag, newTag), extOld, extNew)
File.Move Replace(Replace(File.Path, oldTag, newTag), extOld, extNew)
Else
StdOut.Echo Replace(File.Path, oldTag, newTag)
File.Move Replace(File.Path, oldTag, newTag)
End If

File.Move Replace(File.Path, strfilename, resultString)

FilesRenamed = FilesRenamed + 1
Else
FilesSkipped = FilesSkipped + 1
End If
Next

Dim shape As String
shape = "dbf (*.dbf) |*.dbf"
CommonDialog1.CancelError = True
On Error GoTo FileOpenCancel
CommonDialog1.InitDir = "c:projectdata"
CommonDialog1.Filter = shape
CommonDialog1.DialogTitle = "open dbf"
CommonDialog1.ShowOpen


'This needs to be replaced with your path information.
'dbf_path = App.path
dbf_path = CommonDialog1.FileName

dbf_name = CommonDialog1.FileName

'cnn.Open "Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=" & dbf_path
Dim conStr As String
conStr = "Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=" & dbf_path & ";Exclusive=No;"
cnn.Open conStr

rs.Open dbf_name, cnn, adOpenStatic, adLockReadOnly, adCmdTable

ListView1.ListItems.Clear ' clear list view untuk list rekod baru
ListView1.ColumnHeaders.Clear ' clear field coloum list field baru
ListView1.View = lvwReport

Dim fieldCounter As Integer

For Each fld In rs.Fields ' iterate over the fields
ListView1.ColumnHeaders.Add , , fld.Name
Next fld
While Not rs.EOF
For fieldCounter = 0 To rs.Fields.Count - 1
If fieldCounter = 0 Then
Set itemX = ListView1.ListItems.Add(, , CStr(rs.Fields.Item(fieldCounter).Value))
Else
itemX.SubItems(fieldCounter) = rs.Fields.Item(fieldCounter).Value & ""
End If
Next fieldCounter
rs.MoveNext
Wend

ListView1.Refresh
Exit Sub
FileOpenCancel:
Exit Sub

Read Only File
i have made a program that can save files and i want to make it so the sved files can not be edited in any way this si what i have so far

SFD.ShowDialog()
filename = SFD.FileName
filenamesave = filename & ".rtf"
datafile = New StreamWriter(filenamesave, True)

after this it enters the information to the file but i am gessing it would happen around here

Read From File Help
hello everyone. im trying to learn how to read and write to files. this is a very basic example im working on but im stuck!

it will add records, but not search and read them back in. here is my code - form one is the add form, for 2 is the find form. can anyone see whats wrong?

form one...


Code:
Private Type Record
CustID As String * 5
CustName As String * 15
End Type

Dim Customer As Record 'customer instance
Dim Position As Integer 'integer to hold position of customer

Private Sub cmdAddRec_Click()
Customer.CustID = txtCustNo.Text 'read the customer id into the file
Customer.CustName = txtCustName.Text 'read the customer name into the file
Position = Position + 1 'add one to last position in file to put new record at the end
Open "c:users.dat" For Random As #1 Len = Len(Customer) 'open the file
Put #1, Position, Customer 'put the customer record into the file
Close #1
txtCustNo.Text = "" 'clear text box
txtCustName.Text = "" 'clear text box
End Sub

Private Sub cmdSearch_Click()
Me.Hide
Form2.Show
End Sub

Private Sub Form_Load()
Open "c:users" For Random As #1 Len = Len(Customer) 'open file to read
Position = LOF(1) / Len(Customer) 'division to find last number in record
Close #1 'close the file
End Sub
form 2....


Code:
Private Type Record
CustID As String * 5
CustName As String * 15
End Type

Dim Customer As Record 'customer instance
Dim Position As Integer 'integer to hold position of customer

Private Sub cmdFindUser_Click()
Dim Found As Boolean
Dim RecNumber As Integer 'variable to hold record number
Dim SearchID As String 'string to hold users ID

Found = False
RecNumber = 0
SearchID = txtCustID.Text 'the ID to look for

Open "c:users.dat" For Random As #1 Len = Len(Customer) 'open the file to look in
Do While (Not EOF(1)) And (Found = False) 'loop to search for the ID
RecNumber = RecNumber + 1 'while there is always another record
Get #1, RecNumber, Customer 'get the match if there is one
If Customer.CustID = SearchID Then
Found = True 'set found to true
txtCustNo.Text = Customer.CustID 'display search results in text boxes
txtCustName.Text = Customer.CustName
End If
Loop
Close #1

If Not Found Then
MsgBox "No records found"
End If

txtCustID.Text = "" 'clear search box

End Sub
thanks for any help.

How To Read A Eml File
I need to know how do I import the eml file

Read Xml File
I was wondering, I have no idea how, but I want to dynamically read an XML file file and populate drop down lists. I just have no idea how to read the XML file. Could someone please provide an example or direct me to an example that I can take a look at. I have found complex examples how to write, but I just need a really simple dirty solution for reading various XML files.

Thanks in advance

Read A File
hi,

i've a frame with command1 , and text1, text2

it's my code:

sub form_load()

dim re as string

end sub


sub command1_click()

open "try.txt, 3" for input as 1
re = input $(LOF(1),1)
close(1)

text2.text = re

end sub

in "try.txt" there is "text1.text" (not what is in text1.text but "text1.text)

i'd like to see in text2 what i wrote in textbox give by "try.txt", here text1


Bagbones

Sorry for my english, but i'm french

VB File Read
Can someone help me make a VB program that you can select files from a folder (it can be set to a default folder to look in of D:GarfieldComics if that makes it easier, but would rather be able to browse also) and have it display them in the form window next to a list box where you click the picture you want to see. the files are .jpg
Thank you,
Russ

Read Txt File
In a txt file? there are 10 lines words.

can i use textbox to read the 1st, 3rd, 5th.... lines ?



a novice

Vb Exe File Read Only ??
hi all ...have a super xmas all round.

just a quickie question...is it possible in vb to make an .exe file read only before compiling takes place.how would one do this ???


thanks

john

Read File
I have a simple text file with 3 fields separated by tab.
My problem is that when I open my file and try to read its fields I can't read the last field!!!
Who can help me?
Thx.

Copyright © 2005-08 www.BigResource.com, All rights reserved