-
How to filter a string then manipulate it
Im an extreme newbie, but im really trying to make a program that , you enter
a spanish verb, or latin , in this example
and then it checks to see what vowel it has on the end, and adds the appropiate
endings
But how do you check a string
how do you conditionally alter the string according to the check
-
Re: How to filter a string then manipulate it
"XerosAqua" <XerosAqua@hotmail.com> schreef in bericht
news:3a16f637$1@news.devx.com...
<snip>
> you enter a spanish verb, or latin , in this example
> and then it checks to see what vowel it has on the end,
> and adds the appropiate endings.
> But how do you check a string
> how do you conditionally alter the string according to the check
First you get your string (Me.Text1.Text) and optionally remove alle leading
and or trailing spaces(LTrim$, RTrim$, Trim$).
Then you extract the part you want to check (Left$, Right$, Mid$) and
compare it (StrComp).
If your condition is met then you alter your string, usually by
concatenating string parts (Left$() & strReplacement & Right$()) but can
also use other routines (Replace, Mid$).
HTH
Geert Marttin
-
Re: How to filter a string then manipulate it
Strings have a very useful set of built-in functions that will make this
task relatively easy. If your textbox was named txtVerb for example, I would
approach the problem like this:
(Copy and paste into project)
<<<BEGIN CODE>>>
Private Sub addEnding()
Dim verb As String 'Create new variables to hold
Dim letter As String * 1 'the text and the last letter
Dim ending As String 'as well as the ending.
verb = txtVerb.Text 'Fill the text variable.
letter = Right(verb, 1) 'Get the last letter.
ending = "-as" 'Set your ending.
If letter = "a" Or _
letter = "e" Or _
letter = "i" Or _
letter = "o" Or _
letter = "u" Then 'Check to see if the last letter
'is a vowel, if so...
verb = verb & ending 'add the ending
MsgBox "Your new verb is:" & vbCrLf & vbCrLf & verb
'and present it,
Else 'if not...
MsgBox "Your verb does not end with a vowel."
'inform the user.
End If
End Sub
<<<END CODE>>>
I don't know exactly how experienced you are, so If you need explanations of
any of the functions or code above, either reply to the newsgroup or you can
email me at BOTH zanfar@calviswyant.com and MDWyant@SRPnet.com. I hope this
helps.
Matt Wyant
MDWyant@SRPnet.com
"XerosAqua" <XerosAqua@hotmail.com> wrote in message
news:3a16f637$1@news.devx.com...
>
> Im an extreme newbie, but im really trying to make a program that , you
enter
> a spanish verb, or latin , in this example
> and then it checks to see what vowel it has on the end, and adds the
appropiate
> endings
> But how do you check a string
> how do you conditionally alter the string according to the check
>
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
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks