MedVision ad

im stuck in.... (1 Viewer)

expertdkx

B.IT Network Security
Joined
Feb 7, 2007
Messages
114
Location
Canley Heights
Gender
Male
HSC
2008
Uni Grad
2014
displaying line-by-line into a control array of labels

i.e
x as index

open text file
read line 1
copy value from line 1 to label(x).caption
next line
loop
until EOF of file

but i cant seem to find one that work well..
 

dumarab

Member
Joined
Aug 16, 2007
Messages
260
Gender
Male
HSC
2008
in pascal it's
Code:
[FONT=Arial, Arial, Helvetica]begin[/FONT]
 [FONT=Arial, Arial, Helvetica]counter := 1;[/FONT]
 [FONT=Arial, Arial, Helvetica]assignfile(my_file,'textfile.txt'); [COLOR=#008000]//names.txt is the actual file on disk[/COLOR][/FONT]
 [FONT=Arial, Arial, Helvetica]reset(my_file); [COLOR=#008000]//gets textfile ready for use[/COLOR][/FONT]
 [FONT=Arial, Arial, Helvetica]while not eof(my_file) do[/FONT]
 [FONT=Arial, Arial, Helvetica]  [/FONT][FONT=Arial, Arial, Helvetica]begin[/FONT]
 [FONT=Arial, Arial, Helvetica]  [/FONT][FONT=Arial, Arial, Helvetica]readln(my_file,myarray[counter]);[COLOR=YellowGreen] [COLOR=Green]//reading the line and assigning it [/COLOR][/COLOR]
[/FONT]
  [FONT=Arial, Arial, Helvetica]  [/FONT][FONT=Arial, Arial, Helvetica]counter := counter + 1;[/FONT]
 [FONT=Arial, Arial, Helvetica]  [/FONT][FONT=Arial, Arial, Helvetica]end;[/FONT]
 [FONT=Arial, Arial, Helvetica]closefile(my_file);[/FONT]
  [FONT=Arial, Arial, Helvetica]end;[/FONT]
I can give you the algorithim in Java, C++, Javascript and PHP . I'm not sure with VB (never used it) but they nearly all the same.

But thats just the algorithim so the logic is the hard bit all you need to do is find how to assign a text file to a text file variable for eg in java the object is just textfile then find someway to close the file.
 

miche11e

Member
Joined
Jan 22, 2008
Messages
211
Location
parra
Gender
Female
HSC
2008
in vb its this:
Code:
dim datafile as string
dim item as integer
 
[FONT=Verdana]Public Sub extract()
    Datafile = "E:\group assessment 2008\file.txt"     [COLOR=seagreen]'[/COLOR][SIZE=1][COLOR=seagreen]set the filename to be read from
[/COLOR][/SIZE]    Open Datafile For Input As 1    [COLOR=seagreen]'opens the file[/COLOR]
    item = 0
    
    Do Until EOF(1)         [COLOR=seagreen]'while not at the End Of File keep reading[/COLOR]
        Input #1, Data      [COLOR=seagreen]'extract from the file[/COLOR]
            lstnames.AddItem (Data)    [COLOR=seagreen]'add the data to the list "lstnames"[/COLOR]
        EOF (1)
    Loop
       
    Close #1    [COLOR=seagreen]'close the file
[/COLOR]    a = MsgBox("List succesfully opened.", vbOKOnly, "Opened")
[COLOR=seagreen]'a message box comes up to let the user know that the list has been opened
[/COLOR]End Sub[/FONT]
i used this for our last assesment - hope it helps!!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top