how do i detemen how long a text string...
is in between "hi" and the end of the line
# 1 Re: how do i detemen how long a text string...
Use the InStr function to figure out the location of "hi". Then subtract that value from the length of the stirng (returned by the Len function).
# 2 Re: how do i detemen how long a text string...
but what about if there is more on the next line?
# 3 Re: how do i detemen how long a text string...
Please post an example of the text you want to search and the result you expect.
# 4 Re: how do i detemen how long a text string...
[.ShellClassInfo]
IconFile=
IconIndex=0
(there could be text here)
Start at "IconIndex=" and it gose to the end of the line and in this case it should return 0
and this
[.ShellClassInfo]
IconFile=
IconIndex=123
(there could be text here)
should return "123"
# 5 Re: how do i detemen how long a text string...
OK, I don't see how that has anything to do with your original question. ;-) I would do this (assuming that these lines are in a disk file):
hFile = FreeFile
Open "d:\path\filename.ini" For Input As hFile
Do Until EOF(hFile)
' Read a line
Line Input #hFile, sText
' If line contains "IconIndex"...
If InStr(sText, "IconIndex") Then
' Find equal sign
Equal = InStr(sText, "=")
' If found...
If Equal Then
' Extract text following equal sign,
' trim spaces and convert to value
IconIndex = Val(Trim(Mid(sText, Equal + 1)))
End If
End If
Loop
Close hFile
# 6 Re: how do i detemen how long a text string...
it is in a text box all ready
it is named DesktopText.Text
# 7 Re: how do i detemen how long a text string...
Dim Line As Variant
Dim Lines() As String
Lines = Split(DesktopText.Text, vbCrLf)
For Each Line In Lines
' If line contains "IconIndex"...
If InStr(Line, "IconIndex") Then
' Find equal sign
Equal = InStr(Line, "=")
' If found...
If Equal Then
' Extract text following equal sign,
' trim spaces and convert to value
IconIndex = Val(Trim(Mid(Line, Equal + 1)))
End If
End If
Next
# 8 Re: how do i detemen how long a text string...
thanks