DevX Home Today's Headlines   Articles Archive   Tip Bank   Forums

# Thread: string manipulation - interesting

1. Registered User
Join Date
May 2005
Posts
6

## string manipulation - interesting

Dear all,

This problem if solved will be very handy for people dealing with modeling and simulation stuff. I attached a txt file, which is the results of a simulation that I'm working on. I will need to extract out a certain value from the matrix(end of the text file) to do some calculation. And, I have 500 of these results. So, I hope to develop a VB program to do this for me.

So, the problem is:
How can I extract the second row and third column value (-58.38) and store it in a variable for certain calculation?

Take a look on the txt file. This value is located at the end of the text file, the capacitance matrix. However, it does not always fall on the same line. So, if possible the best bet is to let VB detect the keyword, "GNDL%GNDL" and then go to the third column to grab the value.

Hope someone can guide me out~!

Cheers
Kok Wai

2. try this :

Code:
```Open "C:\output_mucluster_substrate.txt" For Input As #1
Dim row As String
Dim found As Boolean
Do Until EOF(1)
Line Input #1, row
If Left(row, 9) = "GNDL%GNDL" Then found = True: Exit Do
Loop
Close #1
If (found) Then
Dim i As Integer
For i = 1 To Len(row)
While Mid(row, i + 2, 1) = " "
row = Left(row, i) & Mid(row, i + 2)
Wend
Next
Dim col() As String
col = Split(row, " ")
If UBound(col) = -1 Then
MsgBox "Can't find column !"
Else
MsgBox "Value is=" & col(4) 'change 4 by any value u want
End If
Else
MsgBox "Can't find row !"
End If```
changing the value of "4" and "GNDl..." will be general case .

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

 FAQ Latest Articles Java .NET XML Database Enterprise
 Questions? Contact us. C++ Web Development Wireless Latest Tips Open Source