473,387 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how to group similar events?

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
Feb 6 '06 #1
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
Feb 6 '06 #2
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

Feb 6 '06 #3
"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/>

Feb 6 '06 #4
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
Feb 6 '06 #5
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

Feb 7 '06 #6
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
Feb 7 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
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,...
17
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...
1
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...
0
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 –...
0
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...
0
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...
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
marktang
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,...
0
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...
0
jinu1996
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.