convert lawcase to upcase words

Post your questions regarding programming in C# in here.
8 posts Page 1 of 1
Contributors
User avatar
hortencio
New Member
New Member
Posts: 19
Joined: Thu Apr 19, 2012 1:41 am

convert lawcase to upcase words
hortencio
Hi, i would like to know if there is a cod to convert latters from lawcase to upcase while typing any information in the application!!!
GoodGuy17
Coding God
Coding God
Posts: 1610
Joined: Mon Sep 07, 2009 12:25 am

Under the TextChanged event of the textbox, try:
Code: Select all
TextBox1.Text.ToUpper()
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Re: convert lawcase to upcase words
MrAksel
That won't work ^^ Try this instead
Code: Select all
Dim Updt As Boolean = True
Private Sub TextBox1_TextChanged() Handles TextBox1.TextChanged
   If Updt Then
      Updt = False
      TextBox1.Text = TextBox1.Text.ToUpper()
      Updt = True
   End If
End Sub
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
GoodGuy17
Coding God
Coding God
Posts: 1610
Joined: Mon Sep 07, 2009 12:25 am

MrAksel wrote:
That won't work ^^ Try this instead
Code: Select all
Dim Updt As Boolean = True
Private Sub TextBox1_TextChanged() Handles TextBox1.TextChanged
   If Updt Then
      Updt = False
      TextBox1.Text = TextBox1.Text.ToUpper()
      Updt = True
   End If
End Sub
In that case, just use:
Code: Select all
TextBox1.Text = TextBox1.Text.ToUpper()
I don't see a need for the 'Updt" variable.
User avatar
Codex
Coding God
Coding God
Posts: 2028
Joined: Wed Mar 31, 2010 5:50 pm

Re: convert lawcase to upcase words
Codex
The Boolean Updt will always be True, so, like Reboh said, there is no need for the If statement.
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Re: convert lawcase to upcase words
MrAksel
GoodGuy17 wrote:
MrAksel wrote:
That won't work ^^ Try this instead
Code: Select all
Dim Updt As Boolean = True
Private Sub TextBox1_TextChanged() Handles TextBox1.TextChanged
   If Updt Then
      Updt = False
      TextBox1.Text = TextBox1.Text.ToUpper()
      Updt = True
   End If
End Sub
In that case, just use:
Code: Select all
TextBox1.Text = TextBox1.Text.ToUpper()
I don't see a need for the 'Updt" variable.
When you use
Code: Select all
TextBox1.Text = TextBox1.Text.ToUpper()
TextBox1_TextChanged will be called again, and again, and again in an unbreakable loop. The Updt variable will prevent this loop.
Codex wrote:
The Boolean Updt will always be True, so, like Reboh said, there is no need for the If statement.
It will not always be True. It is set to false to prevent the update caused by
Code: Select all
TextBox1.Text = TextBox1.Text.ToUpper()
And set to True again afterwards.
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
User avatar
hortencio
New Member
New Member
Posts: 19
Joined: Thu Apr 19, 2012 1:41 am

TextBox1.Text = TextBox1.Text.ToUpper()
this code worked but when i´m writting the cursor goes back of the word, i mean the words come from right to the left.
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Re: convert lawcase to upcase words
MrAksel
Code: Select all
Dim Updt As Boolean = True
Private Sub TextBox1_TextChanged() Handles TextBox1.TextChanged
   If Updt Then
      Dim Index As Integer = TextBox1.SelectionStart
      Updt = False
      TextBox1.Text = TextBox1.Text.ToUpper()
      Updt = True
      TextBox1.SelectionStart = Index
   End If
End Sub
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
8 posts Page 1 of 1
Return to “General coding help”