I have a function that converts the vbTab to a single white space. What I really need is for the vbTab to be converted to the appropriate number of white spaces that the vbTab covers....in other words, my code does this
one two three four
becomes
one two three four
and I need it to be
one two three four
but be spaces instead of tabs
I have attached my code....maybe it can be modified...
'*************Start Code******************
Public Function dhTranslate(ByVal strIn As String, ByVal strMapIn As String, _
ByVal strMapOut As String) As String
Dim lngI As Long
Dim lngPos As Long
Dim strChar As String * 1
Dim strOut As String
'If there's no list of characters to replace, there's no point going on with the work
If Len(strMapIn) > 0 Then
'Right fill the strMapOut set
If Len(strMapOut) > 0 Then
strMapOut = Left$(strMapOut & String(Len(strMapIn), Right$(strMapOut, 1)), Len(strMapIn))
End If
For lngI = 1 To Len(strIn)
strChar = Mid$(strIn, lngI, 1)
lngPos = InStr(1, strMapIn, strChar, vbBinaryCompare)
If lngPos > 0 Then
'If strMapOut is empty, this doesn't fail, because Mid handles empty strings gracefully
strOut = strOut & Mid$(strMapOut, lngPos, 1)
Else
strOut = strOut & strChar
End If
Next lngI
End If
dhTranslate = strOut
End Function
'****************End Code***************** It's not important that someone else can do in one step what it took you ten to do...the important thing is that you found a solution.![[spin] [spin] [spin]](/data/assets/smilies/spin.gif)
Robert L. Johnson III, A+, Network+, MCP
Access Developer/Programmer
one two three four
becomes
one two three four
and I need it to be
one two three four
but be spaces instead of tabs
I have attached my code....maybe it can be modified...
'*************Start Code******************
Public Function dhTranslate(ByVal strIn As String, ByVal strMapIn As String, _
ByVal strMapOut As String) As String
Dim lngI As Long
Dim lngPos As Long
Dim strChar As String * 1
Dim strOut As String
'If there's no list of characters to replace, there's no point going on with the work
If Len(strMapIn) > 0 Then
'Right fill the strMapOut set
If Len(strMapOut) > 0 Then
strMapOut = Left$(strMapOut & String(Len(strMapIn), Right$(strMapOut, 1)), Len(strMapIn))
End If
For lngI = 1 To Len(strIn)
strChar = Mid$(strIn, lngI, 1)
lngPos = InStr(1, strMapIn, strChar, vbBinaryCompare)
If lngPos > 0 Then
'If strMapOut is empty, this doesn't fail, because Mid handles empty strings gracefully
strOut = strOut & Mid$(strMapOut, lngPos, 1)
Else
strOut = strOut & strChar
End If
Next lngI
End If
dhTranslate = strOut
End Function
'****************End Code***************** It's not important that someone else can do in one step what it took you ten to do...the important thing is that you found a solution.
![[spin] [spin] [spin]](/data/assets/smilies/spin.gif)
Robert L. Johnson III, A+, Network+, MCP
Access Developer/Programmer