473,406 Members | 2,816 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,406 software developers and data experts.

Cumbersome Solution

I ran into a small issue and I found a solution however it is cumbersome to use.

The problem and solution is describe within the MSDN article http://msdn2.microsoft.com/en-us/lib...28(d=ide).aspx

I would like to create one subroutine for all my textboxes and not one for each textbox, given the sample subroutine below, how can I add the textbox name into this subroutine?

Cumbersome Solution

Private Sub SetText(ByVal [text] As String)

' InvokeRequired required compares the thread ID of the

' calling thread to the thread ID of the creating thread.

' If these threads are different, it returns true.

If Me.tb_Netbios.InvokeRequired Then

Dim d As New SetTextCallback(AddressOf SetText)

Me.Invoke(d, New Object() {[text]})

Else

Me.tb_Netbios.Text = [text]

End If

End Sub

Jul 12 '06 #1
2 2329
Garth wrote:
<snip>
I would like to create one subroutine for all my textboxes and not
one for each textbox, given the sample subroutine below, how can I
add the textbox name into this subroutine?
<snip>
Private Sub SetText(ByVal [text] As String)
<snip>
If Me.tb_Netbios.InvokeRequired Then
Dim d As New SetTextCallback(AddressOf SetText)
Me.Invoke(d, New Object() {[text]})
Else
Me.tb_Netbios.Text = [text]
End If
End Sub
One approach is to add the target TextBox as parameter:

Private Delegate Sub SetTextCallback(T As TextBox, V As String)
'...
Private Sub SetText(ByVal Target As TextBox, _
ByVal NewValue As String)
If Target.InvokeRequired Then
Dim D As New SetTextCallback(AddressOf SetText)
Target.Invoke(D, New Object() {Target, NewValue})
Else
Target.Text = NewValue
End If
End Sub
'...
Sub BtnClick(...)
SetText(Me.SomeTextBox, NewValue)
'....
End Sub

HTH.

Regards,

Branco.

Jul 12 '06 #2
Thanks Branco as i'm sure you already know, I'm still very green with
VB.Net.
"Branco Medeiros" <br*************@gmail.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
Garth wrote:
<snip>
> I would like to create one subroutine for all my textboxes and not
one for each textbox, given the sample subroutine below, how can I
add the textbox name into this subroutine?
<snip>
> Private Sub SetText(ByVal [text] As String)
<snip>
> If Me.tb_Netbios.InvokeRequired Then
Dim d As New SetTextCallback(AddressOf SetText)
Me.Invoke(d, New Object() {[text]})
Else
Me.tb_Netbios.Text = [text]
End If
End Sub

One approach is to add the target TextBox as parameter:

Private Delegate Sub SetTextCallback(T As TextBox, V As String)
'...
Private Sub SetText(ByVal Target As TextBox, _
ByVal NewValue As String)
If Target.InvokeRequired Then
Dim D As New SetTextCallback(AddressOf SetText)
Target.Invoke(D, New Object() {Target, NewValue})
Else
Target.Text = NewValue
End If
End Sub
'...
Sub BtnClick(...)
SetText(Me.SomeTextBox, NewValue)
'....
End Sub

HTH.

Regards,

Branco.

Jul 12 '06 #3

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

Similar topics

3
by: Wayne Wengert | last post by:
I have a solution. I want to clone it to try some different options. Is there a way to open Solution A, save it as Solution B and then be able to try some things in Solution B without affecting...
10
by: Simon Jefferies | last post by:
Hello, I'm getting a strange problem where when I load up my solution that has three projects:- a managed C++ .NET, one C++ lib, and a VB library. It locks up and doesn't load completely, I...
0
by: TEK | last post by:
Hello We have a quite huge project. To limit the solution size, rebuild time and so on we have divided the project in two different solution. One solution that holds the buiness entities, or...
6
by: I_AM_DON_AND_YOU? | last post by:
I have a small VB.Net Solution. The solution has filename LABELMAKER.SLN and the the project has filename LABELMAKER.VBPROJ. There is another file LABELMAKER.VBPROJ.USER. All these are in a...
5
by: kai | last post by:
Hi, I use XP Pro and VS2005. I find when I create a new Website, I only see the Project node not Solution. After I add sedcond project under the solution tree, then I see the solution node. How...
1
by: Dave | last post by:
I'm building a vb.net2005 app to have the Outlook look and feel. I've got a lot of panels (1 for each of about 30 buttons down the left side). I'm finding that dealing with 30 panels to be very...
3
by: Manikandan | last post by:
Hi, I'm copying projects from a solution in the vss. In my local system i created solution ,added that project(make modification related to solution) When i added this solution to vss, projects...
0
by: techie | last post by:
List of Solution manuals: Engineering Circuit Analysis 6Ed - Hayt Solutions Manual Norbury - Solutions manual for mechanics and thermodynamics Physics For Scientists And Engineers - Solution...
16
by: =?Utf-8?B?RHdlZWJlcmVsbGE=?= | last post by:
I created an Access 2007 application for my customer. The application is shared by three employees on a server. It maintains a contact list including financial data and social security numbers. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.