469,891 Members | 2,173 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,891 developers. It's quick & easy.

How to retrieve a certain text from .*txt file into textboxes?

;) Hi, I met with some problems with my Visual Basic codings...I need to retrieve certain texts or characters from the text file and place it in each different textboxes...How do i start with? :eek: ...Below is the text file which i needed to retrieve...I need to start reading from [status] to [status end]...How do i code in order to read them line-by-line and retrieving the each numbers into textboxes? :confused:

[Status]
Axis-1
0, 0, 1, 0, 0
300.25, 300.25
Axis-2
0, 0, 0, 0, 1
0, 0
Axis-3
0, 0, 0, 0, 0
50.50, 85.45
[Status End]
[Error]
Axis 1 reached forward limit
All axis at home position
[Error End]
Jul 20 '06 #1
4 2316
Maybe this can get you started

Dim strTemp As String

Open "C:\Test.txt" For Input As #1
Input #1, strTemp
MsgBox strTemp
Close #1
Jul 20 '06 #2
Yup.. :D Thanks for your code, it really helps...but i need to retrieve the Axis-1, Axis-2, Axis-3...and without knowing how many axes are there in the text file..how do i retrieve the all Axis into each different textboxes? Because my programming language is weak...it would be of a great help if u could code it in a more simpler manner...Thanks alot... :)
Jul 21 '06 #3
Maybe this can get you started

Dim strTemp As String

Open "C:\Test.txt" For Input As #1
Input #1, strTemp
MsgBox strTemp
Close #1
-------------------------------------------------------------------------------------------------------------------

Yup.. :D Thanks for your code, it really helps...but i need to retrieve the Axis-1, Axis-2, Axis-3...and without knowing how many axes are there in the text file..how do i retrieve the all Axis into each different textboxes? Because my programming language is weak...it would be of a great help if u could code it in a more simpler manner...Thanks alot.. :rolleyes: .
Jul 21 '06 #4
-------------------------------------------------------------------------------------------------------------------

Yup.. :D Thanks for your code, it really helps...but i need to retrieve the Axis-1, Axis-2, Axis-3...and without knowing how many axes are there in the text file..how do i retrieve the all Axis into each different textboxes? Because my programming language is weak...it would be of a great help if u could code it in a more simpler manner...Thanks alot.. :rolleyes: .

Well I think the focus of these forums is on learning this yourself by searching help files and internet but I will give you one more nudge in the right direction.

After you get the line of text you can test it with the InStr Function

example

Dim strTemp As String

Open "C:\Test.txt" For Input As #1
Input #1, strTemp
MsgBox strTemp
Input #1, strTemp

'##########################################
'Test to see if this line has the string "Axis-1"
If InStr(1, strTemp, "Axis-1", vbTextCompare) Then
MsgBox "This is the Axis-1 Line"
End If
'##########################################

Input #1, strTemp
MsgBox strTemp
Input #1, strTemp
MsgBox strTemp
Input #1, strTemp
MsgBox strTemp
Close #1

each subsequent Input statement will give you the Axis-1 values
Jul 21 '06 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

8 posts views Thread by Fabian Braennstroem | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.