Hello,
I have a group of textboxes where I change the text to lower on leave, but I
am sure there is a more efficient way to do this.
rivate Sub txt1_Leave(...) Handles txt1.Leave
Dim str1 As String = txt1.Text.ToLower
txt1.Text = str1
End Sub
Private Sub txt2_Leave(...) Handles txt2.Leave
Dim str1 As String = txt2.Text.ToLower
txt2.Text = str1
End Sub
Private Sub txtI3_Leave(...) Handles txtIDfld.Leave
Dim str1 As String = txtIDfld.Text.ToLower
txtIDfld.Text = str1
End Sub
Private Sub txt4_Leave(...) Handles txt4.Leave
Dim str1 As String = txt4.Text.ToLower
txt4.Text = str1
End Sub
I think the above can be replaced with something like
Private Sub onLeaving(ByVal sender As Object, ByVal e As System.EventArgs)
handles txt1.leave, txt2.leave, txt3.leave, txt4.leave
Dim str1 As String = sender.ToString.ToLower
sender = str1
End Sub
this line seems to work - str1 appears to get the value from sender
Dim str1 As String = sender.ToString.ToLower
But when I try to reapply the new value to sender as below
sender = str1
nothing happends. The text in the textbox did not get changed. Any
suggestions appreciated what I could do to make this work.
Thanks,
Rich 6 1247
Rich wrote: Hello,
I have a group of textboxes where I change the text to lower on leave, but I am sure there is a more efficient way to do this.
rivate Sub txt1_Leave(...) Handles txt1.Leave Dim str1 As String = txt1.Text.ToLower txt1.Text = str1 End Sub
Private Sub txt2_Leave(...) Handles txt2.Leave Dim str1 As String = txt2.Text.ToLower txt2.Text = str1 End Sub
Private Sub txtI3_Leave(...) Handles txtIDfld.Leave Dim str1 As String = txtIDfld.Text.ToLower txtIDfld.Text = str1 End Sub
Private Sub txt4_Leave(...) Handles txt4.Leave Dim str1 As String = txt4.Text.ToLower txt4.Text = str1 End Sub
I think the above can be replaced with something like
Private Sub onLeaving(ByVal sender As Object, ByVal e As System.EventArgs) handles txt1.leave, txt2.leave, txt3.leave, txt4.leave Dim str1 As String = sender.ToString.ToLower sender = str1 End Sub
this line seems to work - str1 appears to get the value from sender Dim str1 As String = sender.ToString.ToLower
But when I try to reapply the new value to sender as below
sender = str1
nothing happends. The text in the textbox did not get changed. Any suggestions appreciated what I could do to make this work.
Thanks, Rich
Private Sub onLeaving(ByVal sender As Object, ByVal e As System.EventArgs)
handles txt1.leave, txt2.leave, txt3.leave, txt4.leave
Dim str1 As String = DirectCast(sender, TextBox).Text.ToLower
DirectCast(sender, TextBox).Text = str1
End Sub
If you turned on "Option Strict On" at the top of your class you would
have be told about this problem. I recommend always using it.
Chris
Thank you that worked. FYI, I did have option strict on. I did think I
would get a message about sender, but I didn't Hmmm.
Anyway, thanks for your help.
"Chris" wrote: Rich wrote: Hello,
I have a group of textboxes where I change the text to lower on leave, but I am sure there is a more efficient way to do this.
rivate Sub txt1_Leave(...) Handles txt1.Leave Dim str1 As String = txt1.Text.ToLower txt1.Text = str1 End Sub
Private Sub txt2_Leave(...) Handles txt2.Leave Dim str1 As String = txt2.Text.ToLower txt2.Text = str1 End Sub
Private Sub txtI3_Leave(...) Handles txtIDfld.Leave Dim str1 As String = txtIDfld.Text.ToLower txtIDfld.Text = str1 End Sub
Private Sub txt4_Leave(...) Handles txt4.Leave Dim str1 As String = txt4.Text.ToLower txt4.Text = str1 End Sub
I think the above can be replaced with something like
Private Sub onLeaving(ByVal sender As Object, ByVal e As System.EventArgs) handles txt1.leave, txt2.leave, txt3.leave, txt4.leave Dim str1 As String = sender.ToString.ToLower sender = str1 End Sub
this line seems to work - str1 appears to get the value from sender Dim str1 As String = sender.ToString.ToLower
But when I try to reapply the new value to sender as below
sender = str1
nothing happends. The text in the textbox did not get changed. Any suggestions appreciated what I could do to make this work.
Thanks, Rich Private Sub onLeaving(ByVal sender As Object, ByVal e As System.EventArgs) handles txt1.leave, txt2.leave, txt3.leave, txt4.leave Dim str1 As String = DirectCast(sender, TextBox).Text.ToLower DirectCast(sender, TextBox).Text = str1 End Sub
If you turned on "Option Strict On" at the top of your class you would have be told about this problem. I recommend always using it.
Chris
"Rich" <Ri**@discussions.microsoft.com> schrieb: Private Sub onLeaving(ByVal sender As Object, ByVal e As System.EventArgs) handles txt1.leave, txt2.leave, txt3.leave, txt4.leave Dim str1 As String = sender.ToString.ToLower sender = str1 End Sub
this line seems to work - str1 appears to get the value from sender Dim str1 As String = sender.ToString.ToLower
But when I try to reapply the new value to sender as below
sender = str1
'DirectCast(sender, TextBox).Text = str1'.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Rich wrote: Thank you that worked. FYI, I did have option strict on. I did think I would get a message about sender, but I didn't Hmmm.
Anyway, thanks for your help.
"Chris" wrote:
Rich wrote:
Hello,
I have a group of textboxes where I change the text to lower on leave, but I am sure there is a more efficient way to do this.
rivate Sub txt1_Leave(...) Handles txt1.Leave Dim str1 As String = txt1.Text.ToLower txt1.Text = str1 End Sub
Private Sub txt2_Leave(...) Handles txt2.Leave Dim str1 As String = txt2.Text.ToLower txt2.Text = str1 End Sub
Private Sub txtI3_Leave(...) Handles txtIDfld.Leave Dim str1 As String = txtIDfld.Text.ToLower txtIDfld.Text = str1 End Sub
Private Sub txt4_Leave(...) Handles txt4.Leave Dim str1 As String = txt4.Text.ToLower txt4.Text = str1 End Sub
I think the above can be replaced with something like
Private Sub onLeaving(ByVal sender As Object, ByVal e As System.EventArgs) handles txt1.leave, txt2.leave, txt3.leave, txt4.leave Dim str1 As String = sender.ToString.ToLower sender = str1 End Sub
this line seems to work - str1 appears to get the value from sender Dim str1 As String = sender.ToString.ToLower
But when I try to reapply the new value to sender as below
sender = str1
nothing happends. The text in the textbox did not get changed. Any suggestions appreciated what I could do to make this work.
Thanks, Rich Private Sub onLeaving(ByVal sender As Object, ByVal e As System.EventArgs) handles txt1.leave, txt2.leave, txt3.leave, txt4.leave Dim str1 As String = DirectCast(sender, TextBox).Text.ToLower DirectCast(sender, TextBox).Text = str1 End Sub
If you turned on "Option Strict On" at the top of your class you would have be told about this problem. I recommend always using it.
Chris
Actually you wouldn't get the error now that look at it.
'This line you do a string to a string
Dim str1 As String = sender.ToString.ToLower
This one you assign the object to a string
sender = str1
Both of them are allowed since it is an object.
If you just did:
Dim str1 As String = sender
You'd get an error.
Chris
A better way to do it might be in the KeyAscii event to chane upper case keys
to lower case keys so the user sees only lower case being entered into the
text box.
--
Dennis in Houston
"Rich" wrote: Thank you that worked. FYI, I did have option strict on. I did think I would get a message about sender, but I didn't Hmmm.
Anyway, thanks for your help.
"Chris" wrote:
Rich wrote: Hello,
I have a group of textboxes where I change the text to lower on leave, but I am sure there is a more efficient way to do this.
rivate Sub txt1_Leave(...) Handles txt1.Leave Dim str1 As String = txt1.Text.ToLower txt1.Text = str1 End Sub
Private Sub txt2_Leave(...) Handles txt2.Leave Dim str1 As String = txt2.Text.ToLower txt2.Text = str1 End Sub
Private Sub txtI3_Leave(...) Handles txtIDfld.Leave Dim str1 As String = txtIDfld.Text.ToLower txtIDfld.Text = str1 End Sub
Private Sub txt4_Leave(...) Handles txt4.Leave Dim str1 As String = txt4.Text.ToLower txt4.Text = str1 End Sub
I think the above can be replaced with something like
Private Sub onLeaving(ByVal sender As Object, ByVal e As System.EventArgs) handles txt1.leave, txt2.leave, txt3.leave, txt4.leave Dim str1 As String = sender.ToString.ToLower sender = str1 End Sub
this line seems to work - str1 appears to get the value from sender Dim str1 As String = sender.ToString.ToLower
But when I try to reapply the new value to sender as below
sender = str1
nothing happends. The text in the textbox did not get changed. Any suggestions appreciated what I could do to make this work.
Thanks, Rich Private Sub onLeaving(ByVal sender As Object, ByVal e As System.EventArgs) handles txt1.leave, txt2.leave, txt3.leave, txt4.leave Dim str1 As String = DirectCast(sender, TextBox).Text.ToLower DirectCast(sender, TextBox).Text = str1 End Sub
If you turned on "Option Strict On" at the top of your class you would have be told about this problem. I recommend always using it.
Chris
Rich,
Be aware that there are here two criteria for efficient. It is more
efficient to write and maintain. Therefore I use it forever as showed by
others.
However it is less efficient to process (what is a very very very little
bit).
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: SueB |
last post by:
Greetings. I have a report based on the following query (hang in there
... it's quite long):
SELECT Year(.) AS Yr, tblEvents.eventID,
tblEvents.eventname, tblEvents.eventhost,...
|
by: Balaji K |
last post by:
Hi Y'all,
There is a new community for C# developers@
http://groups.msn.com/IndiaCSharpDevelopersGroup
This is a forum for C# Developers and those who wish to become C#
Developers. Just about...
|
by: rivelino83 |
last post by:
Hi all,
I'm looking for an ASP component that manage USER PROFILE, that works similar to (URL address blocked: See forum rules) or (URL address blocked: See forum rules) The features that I would...
|
by: rivelino83 |
last post by:
Hi all,
I'm looking for an ASP component that manage USER PROFILE, that works similar to facebook or mySpace The features that I would like are:
1) profile image.
2) Member photo albums –...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |