|
-
Nov 27th, 2000, 06:39 PM
#1
Thread Starter
Lively Member
Hi,
Appreciate very much if someone can point out my mistake on the code sample below. What I am trying to do is to eliminate the "'" in front and at the back of the date string.
Kind regards
Public mtext As String
Private Sub Command1_Click()
Dim rDate As String
rDate = "'09/07/00'"
mtext = strip34(rDate)
msgbox(mtext) ' THIS MSGBOX RETURNED EMPTY STRING
End Sub
Private Function strip34(mStr As String)
Dim xCount%, iPos%
For xCount% = 1 To 2
iPos% = InStr(mStr, "'")
'Found at first position?
If iPos% = 1 Then
mStr = Mid(mStr, iPos% + 1, Len(Trim(mStr)))
Else
mStr = Mid(mStr, 1, iPos% - 1)
End If
Next xCount%
mtext = mStr
End Function
-
Nov 27th, 2000, 07:06 PM
#2
Hyperactive Member
Loose the % and try again.
-
Nov 27th, 2000, 07:12 PM
#3
Fanatic Member
Code:
Public mtext As String
Private Sub Command1_Click()
Dim rDate As String
rDate = "'09/07/00'"
mtext = strip34(rDate) 'mtext is assigned the value returned by strip34
MsgBox (mtext) ' THIS MSGBOX RETURNED EMPTY STRING
End Sub
Private Function strip34(mStr As String) As String
Dim xCount%, iPos%
For xCount% = 1 To 2
iPos% = InStr(mStr, "'")
'Found at first position?
If iPos% = 1 Then
mStr = Mid(mStr, iPos% + 1, Len(Trim(mStr)))
Else
mStr = Mid(mStr, 1, iPos% - 1)
End If
Next xCount%
strip34 = mStr 'ASSIGN THE VALUE OF mStr to be returned by this function
End Function
{Insert random techno-babble here}
{Insert quote from some long gone mofo here}
-
Nov 27th, 2000, 08:34 PM
#4
_______
<?>
Code:
Option Explicit
Public mtext As String
Private Sub Command1_Click()
Dim rDate As String
rDate = "'09/07/00'"
rDate = strip34(rDate)
MsgBox mtext
End Sub
Public Function strip34(mStr As String) As String
Dim xCount As Integer, intLen As Integer
intLen = Len(mStr)
For xCount = 1 To intLen
If Mid(mStr, xCount, 1) = "'" Then Mid(mStr, xCount, 1) = " "
Next xCount
mStr = Trim(mStr)
mtext = mStr
End Function
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Nov 27th, 2000, 08:35 PM
#5
Thread Starter
Lively Member
Thanks YoungBuck, it is working now!
Magic word is strip34 = mstr
kind regards
-
Nov 27th, 2000, 08:40 PM
#6
Thread Starter
Lively Member
Many thanks to all those who has responded to my problem above.
Kind regards
-
Nov 27th, 2000, 08:43 PM
#7
_______
<?>
If you have VB6 there is also Replace
rDate = replace(rdate,"'","")
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Nov 27th, 2000, 10:51 PM
#8
Thread Starter
Lively Member
Thanks to HeSaidJoe, Replace function pointed is even more efficient.
Best regards
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|