Article ID: 109825
Article Last Modified on 1/18/2007
Option Compare Binary
' Otherwise, the function will replace spaces with percent signs.
Option Explicit
'============================================================
'The following function will:
' - Find the tabs in a Text or Memo field.
' - Call another function to replace the tabs.
'============================================================
Function FindTabs (WhichField As String) as String
Dim x As Integer, strText As String
Dim start As Integer
start = 1
x = 1
strText = WhichField
Do Until x = 0
' Chr(9) is the Tab character.
' Replace Chr(9) with the ANSI code for the character
' you are searching for.
x = InStr(start, strText, Chr(9))
start = x + 1
If x > 0 And Not IsNull(x) Then
strText = ReplaceTabs(x, strText)
End If
Loop
FindTabs = strText
End Function
'==================================================================
' The following function is called from the FindTabs() function. It
' accepts two arguments, strText and start. The function replaces
' tabs with %. It returns the updated text.
'==================================================================
Function ReplaceTabs(start As Integer, strText As String) As String
' Replace % with the character you want to substitute.
Mid(strText, start, 1) = "%"
ReplaceTabs = strText
End Function
FindTabs(<[fieldname]>)
Additional query words: find/replace recognize
Keywords: kbhowto kbprogramming kbusage KB109825