Ok, let's say I have a variable named Word.
Lets say word's value is 30
I have a txt file with 40 words in it
I want to add to a txtbox the 30th word (word's value)
Is there a way to do it?
Printable View
Ok, let's say I have a variable named Word.
Lets say word's value is 30
I have a txt file with 40 words in it
I want to add to a txtbox the 30th word (word's value)
Is there a way to do it?
Assuming that each line in the TextFile has a CarriageReturn, then like:
VB Code:
Option Explicit Dim strArr() As String Private Sub Form_Load() On Error GoTo Err_Handler 'Open and load the Array with the Text File Open App.Path & "\TextFile.txt" For Input As #1 strArr = Split(Input(LOF(1), 1), vbCrLf) Close #1 Exit Sub Err_Handler: MsgBox "Number: " & Err.Number & vbCrLf & _ "Description: " & Err.Description, vbOKOnly + vbInformation, "File I/O Error" End Sub Private Sub Command1_Click() 'Display the Data specified by Line number MsgBox strArr(Text1.Text) + 1 End Sub
Bruce.