[help]Switching text to another letter

Posts 1–15 of 15 · Page 1 of 1
[help]Switching text to another letter
ok so the title isn't very clear but here is what i need to do(i have searched im not sure if i searched right because i don't really know what to type but) i want it so if there is a / in a label it will turn the / into a -

thanks in advance even if u can't help me.
i get it, i think, like how when u type a & in a label it underscores the text. Why the hell don't u just put a - in the label instead of /
Quote Originally Posted by cosconub View Post
i get it, i think, like how when u type a & in a label it underscores the text. Why the hell don't u just put a - in the label instead of /
no like it changes all the a's in the label to b's.
label1.text.replace("/", "-") ????
Code:
Label1.Text = Label1.Text.Replace("/","-")
If you need to replace multiple items, then use the following format:

Code:
Label1.Text = Label1.Text.Replace("A",a").Replace("B","b").Replace("C","c")
...
Quote Originally Posted by Hassan View Post
Code:
Label1.Text = Label1.Text.Replace("/","-")
If you need to replace multiple items, then use the following format:

Code:
Label1.Text = Label1.Text.Replace("A",a").Replace("B","b").Replace("C","c")
...
[php]
For each m as match in Regex.Matches(Label1.Text, "[ABC]")
Label1.Text = Label1.Text.Replace(m.value, m.value.tolower)
next
[/php]

Quote Originally Posted by Jason View Post


[php]
For each m as match in Regex.Matches(Label1.Text, "[ABC]")
Label1.Text = Label1.Text.Replace(m.value, m.value.tolower)
next
[/php]

Mate, overkill
Quote Originally Posted by freedompeace View Post
Mate, overkill
No shit lol, I just like Regex and giving Hassan shit 'cos he forgot a lot of it

Although I do like this function, very VERY occasionally comes in handy :P

[php]
Private Function ReplaceText(ByVal original As String, ByVal replaceWhat() As String, ByVal replaceWith() As String, ByVal ignorecase As Boolean) As String
If replaceWhat.Count = replaceWith.Count Then
For i As Integer = 0 To replaceWhat.Count - 1
If ignorecase Then
original = original.ToLower.Replace(replaceWhat(i).ToLower, replaceWith(i).ToLower)
Else
original = original.Replace(replaceWhat(i), replaceWith(i))
End If
Next
Else
MsgBox("arrays not the same size")
End If
Return original
End Function

'...
textBox1.Text = ReplaceText(TextBox1.Text, New String() {"A", "B", "C", "D"}, New String() {"x", "y", "z", "w"}, false)
[/php]

(Yes i'm procrastinating from study)
Quote Originally Posted by Jason View Post


No shit lol, I just like Regex and giving Hassan shit 'cos he forgot a lot of it

Although I do like this function, very VERY occasionally comes in handy :P

[php]
Private Function ReplaceText(ByVal original As String, ByVal replaceWhat() As String, ByVal replaceWith() As String, ByVal ignorecase As Boolean) As String
If replaceWhat.Count = replaceWith.Count Then
For i As Integer = 0 To replaceWhat.Count - 1
If ignorecase Then
original = original.ToLower.Replace(replaceWhat(i).ToLower, replaceWith(i).ToLower)
Else
original = original.Replace(replaceWhat(i), replaceWith(i))
End If
Next
Else
MsgBox("arrays not the same size")
End If
Return original
End Function

'...
textBox1.Text = ReplaceText(TextBox1.Text, New String() {"A", "B", "C", "D"}, New String() {"x", "y", "z", "w"}, false)
[/php]

(Yes i'm procrastinating from study)
I've never seen this before "ByVal replaceWhat() As String"... Why () after the variable name? ._.

Also err, RegEx comes in handy when filtering emails, BBCode creation and filtering user input like birthdays.
Quote Originally Posted by freedompeace View Post
I've never seen this before "ByVal replaceWhat() As String"... Why () after the variable name? ._.

Also err, RegEx comes in handy when filtering emails, BBCode creation and filtering user input like birthdays.
() denotes an array, so the function requires you to pass 2 string arrays into it. (thought you would know something basic like this)

i.e
things to replace{"hello", "this", "is", "a", "test""}
replace with (same order as first array) {"i", "höpe", "this", "works", "good"}

hello will be replaced with "i"
"this" will be replaced with "hope"
"is" will be repaced with "This"
...etc

Easy way of replacing multiple things.

As a sidenote, regex is useful for a lot more than filtering emails etc...there are many many cases where it can be extremely useful.
Quote Originally Posted by Jason View Post

() denotes an array, so the function requires you to pass 2 string arrays into it. (thought you would know something basic like this)

i.e
things to replace{"hello", "this", "is", "a", "test""}
replace with (same order as first array) {"i", "höpe", "this", "works", "good"}

hello will be replaced with "i"
"this" will be replaced with "hope"
"is" will be repaced with "This"
...etc

Easy way of replacing multiple things.

As a sidenote, regex is useful for a lot more than filtering emails etc...there are many many cases where it can be extremely useful.
Oh woops --"

Looked like a function to me ~.~

Even in Visual Basic, I use [] to denote an array. It so much easier than distinguishing between a function with a paramter or an array when you're using a complex, long line of code.
Quote Originally Posted by Jason View Post


[php]
For each m as match in Regex.Matches(Label1.Text, "[ABC]")
Label1.Text = Label1.Text.Replace(m.value, m.value.tolower)
next
[/php]
Don't mess with me kid.

@freedompeace: Lol what ? You really used '[]' in Visual Basic to donate an array or you trolling me ? LOL
Quote Originally Posted by Hassan View Post


Don't mess with me kid.

@freedompeace: Lol what ? You really used '[]' in Visual Basic to donate an array or you trolling me ? LOL
I'm better than you at VB, remember? .

@freedom, () does't really look like a function at all, I have no problems reading a long line of code where () is used to denote an array, but maybe that's just me.
Quote Originally Posted by Jason View Post


I'm better than you at VB, remember? .

@freedom, () does't really look like a function at all, I have no problems reading a long line of code where () is used to denote an array, but maybe that's just me.
Serious trolling was serious !

And you remember what Brinuz said about freedom ! /
Quote Originally Posted by Hassan View Post


Serious trolling was serious !

And you remember what Brinuz said about freedom ! /
I do /

Also, serious screencapping was serious !
And done with your own application /
Posts 1–15 of 15 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us