instr() error question *resolved*
The line
VB Code:
textlocation = InStr(start, text, test, vbTextCompare)
produces an error, but I can't figure out why... This is part of a larger sub, but I don't want to bore you guys with that :D
Does anyone know why this is giving an error :confused: ??
VB Code:
'declarations'
Dim dbase As Database
Dim recset As Recordset
Dim length As Integer
Dim str As String
Dim htmltag As String
Dim str2 As String
Dim result As String
Dim textlocation As Long
Dim start As Integer
Dim endlocation As Long
Set dbase = OpenDatabase(dblocation)
start = 0
Do
'look for the space and replace with   tag'
test = Chr(32)
textlocation = InStr(start, text, test, vbTextCompare)
start = textlocation
'exit the do in case of nothing found. The 0 value would cause errors in the subsequent lines'
If textlocation = 0 Then
Exit Do
End If
'read the part before the space, the -1 ensures the space itself is not read'
str = Mid(text, 1, (textlocation - 1))
'read the part after the space, the +1 ensures the space itself is not read'
str2 = Mid(text, (textlocation + 1))
'insert the space tag in between'
text = str & "   " & str2
Loop Until textlocation = 0
Re: instr() error question
You start your search from the first character, i.e
start=1