Access - Strip Tabs From a String

I wanted to strip the tabs from an Access memo field that caused crazy behaviours when I pasted text from other sources into it.  So... I went looking.  MSFT has a nice sample:

 

 

'============================================================
' The following function will:
'   - Find the tabs in a Text or Memo field.
'   - Call another function to remove the tabs.
============================================================

Function FindTabs(WhichField As String) As String
   Dim intCounter As Integer
   Dim strText As String
   Dim intStart As Integer
	   
   intStart = 1
   intCounter = 1
   strText = WhichField
	   
   Do Until intCounter = 0
      ' Chr(9) is the Tab character.
      ' Replace Chr(9) with the ANSI code for the character
      ' you are searching for.
      intCounter = InStr(intStart, strText, Chr(9))
      intStart = intCounter + 1
      If intCounter > 0 And Not IsNull(intCounter) Then
      strText = RemoveTabs(intCounter, strText)
      End If
   Loop
	   
   FindTabs = strText
End Function
'==================================================================
' The following function is called from the FindTabs() function. It
' accepts two arguments, intStart and strText. The function removes tabs
' from the field. It returns the updated text.
'==================================================================   
Function RemoveTabs(intstart As Integer, strText As String) As String
   Dim front As String, rear As String
   front = Left(strText, intstart - 1)
   rear = Mid(strText, intstart + 1)
   RemoveTabs = front & rear
End Function

 

 

 

http://support.microsoft.com/?kbid=210433

 

 

tags: vba, access, strip, tab, character, replace

Related Scribbles:
  • Microsoft Access Links
  • VBscript / ASP Notes


  • ID: 942
    Author:
    leonard
    Date Updated:
    2010-01-30 00:54:37
    Date Created:
    2010-01-30 00:54:37

    Edit

    Comments?
     >> Leonard Chan's Homepage  >> Scribble Web  >> Access - Strip Tabs From a String
    leonard.lotus-land.ca is hosted by Perceptus Solutions Inc.