Sub SetLabels(sFileName as string, nLine as integer)
dim fIn as integer
dim iLfd as integer
dim sZeile as string
dim oLbl as label
fIn=freefile
open app.path & "\" & sFileName for Input Access ReadOnly as #fIn
iLfd=0
do while (iLfd<nLine) and (not eof(fIn))
iLfd=iLfd+1
line input #fIn, sZeile
loop
if eof(fIn) then
' do whatever you want as error recovery
else
' Set Label captions (supposed that the labels are
' members of a controlarray called lblArray and has
' indexes running from 1 to 37
for each oLbl in lblArray
oLbl.Caption=""
next
for each oLbl in lblArray
iLfd=instr(sZeile,",")
if iLfd=0 then
oLbl.caption=sZeile
exit for ' last Element of sZeile reached
else
oLbl.caption=left(sZeile,i
sZeile=mid(sZeile,iLfd+1)
endif
next
endif
close #fIn
end sub
Main Topics
Browse All Topics





by: taplinPosted on 1999-09-03 at 10:21:00ID: 2021559
This should work for you... just use the RetrieveStrings sub to retrieve the strings, and the TransferLine sub to display the strings. Just change the filename in RetrieveStrings, and set up the appropriate label/field names in TransferLine.
Call TransferLine like this:
TransferLine Index
Where Index is the number line in the file you want to show.
Private pstrArray() As String
Private plngCounter As Long
Private Sub RetrieveStrings()
Dim intFreeFile As Integer
Dim strTemp As String
intFreeFile = FreeFile
Open App.Path & "\test.txt" For Input As #intFreeFile
Do Until EOF(intFreeFile)
Line Input #intFreeFile, strTemp
ReDim Preserve pstrArray(plngCounter)
pstrArray(plngCounter) = strTemp
plngCounter = plngCounter + 1
Loop
Close
End Sub
Private Sub TransferLine(Index As Long)
Dim strData() As String
strData = Split(pstrArray(Index), ",")
Me.lable0.Caption = strData(0)
Label1.Caption = strData(1)
End Sub