Editing a String 
Author Message
 Editing a String

Can I have the user input a Sting in a text box like "How are You?"
and then have the program change it to "How+are+you?"

In other words just change the spaces to plus signs.

                                    Thanks,
                                            Andy Phelan



Sun, 25 Nov 2001 03:00:00 GMT  
 Editing a String

Quote:
>In other words just change the spaces to plus signs.

In VB6, this is simple with the Replace() function.  :)

Replace("How are you?",Space(1),"+")

The call above will return the string "How+are+you?".  Of course, with versions
below VB6, you may need to write your own using InStr() and Mid()...several
examples of this should exist on the various VB code repository sites.

-Curtis Spendlove
-Solstice Software



Sun, 25 Nov 2001 03:00:00 GMT  
 Editing a String
This will do it:

===== START OF CODE

Private Sub Form_Load()
rem     create a command button named command1
rem     create a text box named text1
rem     run this source, enter some text and then press the button
Text1.Text = ""
Command1.Caption = "Convert"
End Sub

Private Sub Command1_Click()
rem    this routine analyzes the text1.text and converts every
rem    space into "+"
temp = Text1.Text
For chk = 1 To Len(Text1.Text)
 If Mid$(Text1.Text, chk, 1) = " " Then Mid$(temp, chk, 1) = "+"
Next chk
Text1.Text = temp
End Sub

===== END OF CODE
mad-cowz heeft geschreven in bericht

Quote:
>Can I have the user input a Sting in a text box like "How are You?"
>and then have the program change it to "How+are+you?"

>In other words just change the spaces to plus signs.

>                                    Thanks,
>                                            Andy Phelan



Sun, 25 Nov 2001 03:00:00 GMT  
 Editing a String
hummm... wouldn't it be faster using the InStr function?

Quote:

> This will do it:

> ===== START OF CODE

> Private Sub Form_Load()
> rem     create a command button named command1
> rem     create a text box named text1
> rem     run this source, enter some text and then press the button
> Text1.Text = ""
> Command1.Caption = "Convert"
> End Sub

> Private Sub Command1_Click()
> rem    this routine analyzes the text1.text and converts every
> rem    space into "+"
> temp = Text1.Text
> For chk = 1 To Len(Text1.Text)
>  If Mid$(Text1.Text, chk, 1) = " " Then Mid$(temp, chk, 1) = "+"
> Next chk
> Text1.Text = temp
> End Sub

> ===== END OF CODE
> mad-cowz heeft geschreven in bericht

> >Can I have the user input a Sting in a text box like "How are You?"
> >and then have the program change it to "How+are+you?"

> >In other words just change the spaces to plus signs.

> >                                    Thanks,
> >                                            Andy Phelan

--




Mon, 26 Nov 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Edit Resource strings

2. Edit String for search

3. Simple String Edit

4. edit string table.res

5. listview, scrolling, editing string questions.

6. Resource Editor - unable to edit strings.

7. couple questions about Listview, scrolling, and editing strings

8. DHTML Edit Control, RTF Edit Control, Access 97 Client, SQLServer 7.0 Back End

9. Code for Edit|Copy, Edit|Paste

10. DHTML Edit Control, RTF Edit Control, Access 97 Client, SQLServer 7.0 Back End

11. Date Edit / Currency Edit

12. edit or not edit !!! ;-)

 

 
Powered by phpBB® Forum Software