473,378 Members | 1,280 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Strip Characters

Hello,

I have a textbox "Fname" where users input what they would like a
filename to be. I would like to strip out all invalid characters with
an "After Update" Event.

I have searched other strings and attempted to use other suggested
code, but I was unsucessful.

Does anyone have suggestions or more specific instructions on how to
use the following code.

Thank you in advance!

' --------------------------------------------------
' Function StripString()
'
' Returns a string minus a set of specified chars.
' --------------------------------------------------
Function StripString(MyStr As Variant) As Variant
On Error GoTo StripStringError

Dim strChar As String, strHoldString As String
Dim i As Integer

' Exit if the passed value is null.
If IsNull(MyStr) Then Exit Function

' Exit if the passed value is not a string.
If VarType(MyStr) <8 Then Exit Function

' Check each value for invalid characters.
For i = 1 To Len(MyStr)
strChar = Mid$(MyStr, i, 1)
Select Case strChar
Case ".", "#", ",", "-"
' Do nothing
Case Else
strHoldString = strHoldString & strChar
End Select
Next i

' Pass back corrected string.
StripString = strHoldString

StripStringEnd:
Exit Function

StripStringError:
MsgBox Error$
Resume StripStringEnd
End Function

Jan 29 '07 #1
3 2828
I only glanced at your function. Have you tried using it in the "Before
Update" event?

"Drum2001" <dr******@gmail.comwrote in message
news:11**********************@k78g2000cwa.googlegr oups.com...
Hello,

I have a textbox "Fname" where users input what they would like a
filename to be. I would like to strip out all invalid characters with
an "After Update" Event.

I have searched other strings and attempted to use other suggested
code, but I was unsucessful.

Does anyone have suggestions or more specific instructions on how to
use the following code.

Thank you in advance!

' --------------------------------------------------
' Function StripString()
'
' Returns a string minus a set of specified chars.
' --------------------------------------------------
Function StripString(MyStr As Variant) As Variant
On Error GoTo StripStringError

Dim strChar As String, strHoldString As String
Dim i As Integer

' Exit if the passed value is null.
If IsNull(MyStr) Then Exit Function

' Exit if the passed value is not a string.
If VarType(MyStr) <8 Then Exit Function

' Check each value for invalid characters.
For i = 1 To Len(MyStr)
strChar = Mid$(MyStr, i, 1)
Select Case strChar
Case ".", "#", ",", "-"
' Do nothing
Case Else
strHoldString = strHoldString & strChar
End Select
Next i

' Pass back corrected string.
StripString = strHoldString

StripStringEnd:
Exit Function

StripStringError:
MsgBox Error$
Resume StripStringEnd
End Function

Jan 29 '07 #2
I didnt try, however, I get an error. Basically it cant find the
object...

On Jan 29, 12:15 pm, "paii, Ron" <p...@packairinc.comwrote:
I only glanced at your function. Have you tried using it in the "Before
Update" event?

"Drum2001" <drum2...@gmail.comwrote in messagenews:11**********************@k78g2000cwa.g ooglegroups.com...
Hello,
I have a textbox "Fname" where users input what they would like a
filename to be. I would like to strip out all invalid characters with
an "After Update" Event.
I have searched other strings and attempted to use other suggested
code, but I was unsucessful.
Does anyone have suggestions or more specific instructions on how to
use the following code.
Thank you in advance!
' --------------------------------------------------
' Function StripString()
'
' Returns a string minus a set of specified chars.
' --------------------------------------------------
Function StripString(MyStr As Variant) As Variant
On Error GoTo StripStringError
Dim strChar As String, strHoldString As String
Dim i As Integer
' Exit if the passed value is null.
If IsNull(MyStr) Then Exit Function
' Exit if the passed value is not a string.
If VarType(MyStr) <8 Then Exit Function
' Check each value for invalid characters.
For i = 1 To Len(MyStr)
strChar = Mid$(MyStr, i, 1)
Select Case strChar
Case ".", "#", ",", "-"
' Do nothing
Case Else
strHoldString = strHoldString & strChar
End Select
Next i
' Pass back corrected string.
StripString = strHoldString
StripStringEnd:
Exit Function
StripStringError:
MsgBox Error$
Resume StripStringEnd
End Function- Hide quoted text -- Show quoted text -
Jan 29 '07 #3
What Object?

Are you calling it with something like the following?

me![ControlName] = StripString(me![ControlName])

It that don't work test the function in the debug window.

?StripString("Test#String")

Should return "TestString"

"Drum2001" <dr******@gmail.comwrote in message
news:11**********************@h3g2000cwc.googlegro ups.com...
I didnt try, however, I get an error. Basically it cant find the
object...

On Jan 29, 12:15 pm, "paii, Ron" <p...@packairinc.comwrote:
I only glanced at your function. Have you tried using it in the "Before
Update" event?

"Drum2001" <drum2...@gmail.comwrote in
messagenews:11**********************@k78g2000cwa.g ooglegroups.com...


Hello,
I have a textbox "Fname" where users input what they would like a
filename to be. I would like to strip out all invalid characters with
an "After Update" Event.
I have searched other strings and attempted to use other suggested
code, but I was unsucessful.
Does anyone have suggestions or more specific instructions on how to
use the following code.
Thank you in advance!
' --------------------------------------------------
' Function StripString()
'
' Returns a string minus a set of specified chars.
' --------------------------------------------------
Function StripString(MyStr As Variant) As Variant
On Error GoTo StripStringError
Dim strChar As String, strHoldString As String
Dim i As Integer
' Exit if the passed value is null.
If IsNull(MyStr) Then Exit Function
' Exit if the passed value is not a string.
If VarType(MyStr) <8 Then Exit Function
' Check each value for invalid characters.
For i = 1 To Len(MyStr)
strChar = Mid$(MyStr, i, 1)
Select Case strChar
Case ".", "#", ",", "-"
' Do nothing
Case Else
strHoldString = strHoldString & strChar
End Select
Next i
' Pass back corrected string.
StripString = strHoldString
StripStringEnd:
Exit Function
StripStringError:
MsgBox Error$
Resume StripStringEnd
End Function- Hide quoted text -- Show quoted text -

Jan 29 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Giampiero Gabbiani | last post by:
Hi to all, Is there a simple way to implement a strip algorithm on std::string using STL? I'm sure that it's possible to implement it using some transform, but my knowledge of STL is POOR. ...
3
by: alex.mcshane | last post by:
Hi - I would be grateful for any advice on the following. Within DB2 for OS/390, the STRIP Scaler Function is available. Its function is, for example, to remove leading zeros from a string. ...
6
by: Mark C | last post by:
All, Is there such a function that can strip all non alpha ( not between a-z) characters from a string? I have a function that I currently use that will strip one character at a time from a...
5
by: dan.j.weber | last post by:
I'm using Python 2.3.5 and when I type the following in the interactive prompt I see that strip() is not working as advertised: >>>s = 'p p:p' >>>s.strip(' :') 'p p:p' Is this just me or...
4
by: Steve | last post by:
Hi, I'm a complete PHP n00b slowly finding my way around I'm using the following function that I found on php.net to strip out html and return only the text. It works well except for when you...
6
by: eight02645999 | last post by:
hi can someone explain strip() for these : 'example' when i did this: 'abcd,words.words'
1
by: Mel | last post by:
Hello, How do I strip the last to 2 characters? It is form a html page of labels converted to xml by htmlagility pack, only some of the records, have the hexadecimal character at the end. ...
3
by: Colin J. Williams | last post by:
The Library Reference has strip( ) Return a copy of the string with the leading and trailing characters removed. The chars argument is a string specifying the set of characters to be removed....
6
by: Christoph Zwerschke | last post by:
In Python programs, you will quite frequently find code like the following for removing a certain prefix from a string: if url.startswith('http://'): url = url Similarly for stripping...
4
by: Poppy | last post by:
I'm using versions 2.5.2 and 2.5.1 of python and have encountered a potential bug. Not sure if I'm misunderstanding the usage of the strip function but here's my example. var = "detail.xml"...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.