Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading Values

Status
Not open for further replies.

codenovice

IS-IT--Management
Dec 4, 2001
11
US
I have the values, in a .txtfile,some seperated by a space some NOT. For example
6 01 11 1 19 59 44.0-9.103678166866D-07-1.136868377216D-13

In this 6 is one value,
01 is another,
-9.103678166866D-07 is another.

NOT all values are space delimited.

These values use hexa decimal values and the length is constant for any similar .txt file.
i.e the length remains same for a similar value in a similar file.

Now I need read these values for my programs.

Kindly Help\
Codenovice
 
are the values at least always separated whether using a space or -?
 
No, some of them are some are NOT.I have no other option than to read like this.

Thanks for the prompt response
 
Is there a way that you can determine how these values are entered? How are you supposed to know where one value ends and one begins if they are all stuffed in there like that? If you know that much you could write a routine that parses it for you by determinining whether there is a space delimiter or whether it is hexa decimal or what have you.
 
If you are sure that the lengths will remain the same you can create a custom parser, it is very propriatary. I wrote one up just to test it out.

Private Sub Form_Load()
Const SS = "6 01 11 1 19 59 44.0-9.103678166866D-07-1.136868377216D-13"
Dim i As Integer
Dim aryDataFormat(1, 8) As Variant
Dim ms As String

Call getFormatArray(aryDataFormat)
ms = ""
For i = 0 To UBound(aryDataFormat, 2)
ms = ms & vbCrLf & Mid(SS, aryDataFormat(0, i), aryDataFormat(1, i))
Next i
MsgBox ms
End Sub

Private Sub getFormatArray(ByRef aryDataFormat As Variant)
' 1st index is start position
' 2nd index is length of data

' Value 1
aryDataFormat(0, 0) = "1"
aryDataFormat(1, 0) = "1"

' Value 2
aryDataFormat(0, 1) = "3"
aryDataFormat(1, 1) = "2"

' Value 3
aryDataFormat(0, 2) = "6"
aryDataFormat(1, 2) = "2"

' Value 4
aryDataFormat(0, 3) = "10"
aryDataFormat(1, 3) = "1"

' Value 5
aryDataFormat(0, 4) = "12"
aryDataFormat(1, 4) = "2"

' Value 6
aryDataFormat(0, 5) = "15"
aryDataFormat(1, 5) = "2"

' Value 7
aryDataFormat(0, 6) = "18"
aryDataFormat(1, 6) = "4"

' Value 8
aryDataFormat(0, 7) = "22"
aryDataFormat(1, 7) = "19"

' Value 9
aryDataFormat(0, 8) = "41"
aryDataFormat(1, 8) = "19"
End Sub


Good Luck,
-MattU
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top