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

How to Dynamically Call Various Routines in VB.NET?

I would like to know how to call various routines dynamically using
VB.NET.

Let say I have a class called CMyBarcodeReader that needs to send a
barcode number that it has received from scanner to a routine called
HandleBarcodeNum() in one of these forms: frmOne, frmTwo, and frmThree.
Obviously, it should send the barcode number only to the currently
opened form, and the current form can be frmOne, frmTwo, or frmThree. I
can think of two possible ways to handle this:

One way is to pass the address of one of the HandleBarcodeNum() routine
to CMyBarcodeReader like what a C program may do. But I have no idea
how to do this in VB.NET. Can someone point me an example or some
useful keywords?

Another way that I can think of is to pass a flag to CMyBarcodeReader
class to indicate the currently opened form that it should send. And
then, when CMyBarcodeReader needs to send the barcode number to
HandleBarcodeNum() routine, it can check the flag and then call the
appropriate function. In other words, the code is like this:

CMyBarcodeReader:
..
..
Select(Me.m_sSendToFormName)
Case "frmOne"
Call frmOne.HandleBarcodeNum(sBarcodeNum)
Case "frmTwo"
Call frmTwo.HandleBarcodeNum(sBarcodeNum)
Case "frmThree"
Call frmThree.HandleBarcodeNum(sBarcodeNum)
End Select
..
..

The HandleBarcodeNum() routine will be defined like this in each form:

Public Shared Sub HandleBarcodeNum(ByVal sBarcodeNum As String)
....
End Sub

The problem is that I get syntax error when I refer to data elements of
the form. Seem like that routine "may" not get access to data elements
of that instance of form, and seem like a Public-Shared-Sub "may" only
get access to some kind of static data elements or class-level data
elements. How should I handle this situation? Can someone show me the
correct syntax or an example?

Is there a better way to do this?
Thanks in advance for any info.

Jay Chan

Nov 22 '05 #1
2 2398
Jay,

When you are thinking in operating assynchronosly between applications, you
would not have to think in my opinion in sending and receiving.

Do think in filling a queue and reading a queue. The reason is, that you can
difficult prevent that your reader is alreaydy reading while the other
process is still busy to process.

That is one of the purposes of vbNet remoting.

http://msdn.microsoft.com/library/de...ngoverview.asp

I hope that it gives some idea's

Cor


Nov 22 '05 #2
The .NET remoting seems to be a bit more involved than I need. The
reason is that the functions are all within one application running in
the same handheld.

Anyway, I have fixed this problem by doing these:

- Create a frmBarcodeReader form class and let the main-form to
inherit from it. This simply adds the barcode scanning functionality to
the main form instead of using a separated object to handle barcode
scanning.

- The frmBarcodeReader raises an event whenever it gets a barcode
number, and the main-form handles the event, and forward the event to
the sub-forms.

- Because the main form creates all the sub-forms, it knows exactly
which form needs to receive the barcode number and it has access to the
sub-form instances. By doing this way, the main form can properly call
the public-shared-function in each sub-form to pass the barcode number
to it.

Jay Chan

Nov 22 '05 #3

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

Similar topics

1
by: jaykchan | last post by:
I would like to know how to call various routines dynamically using VB.NET. Let say I have a class called CMyBarcodeReader that needs to send a barcode number that it has received from scanner...
2
by: Briand | last post by:
In my previous posting I failed miserably, to give enough information to get my difficulty apparent. So to start again. I want to create textboxes dynamically in VB.NET. This is not a web...
24
by: | last post by:
Hi, I need to read a big CSV file, where different fields should be converted to different types, such as int, double, datetime, SqlMoney, etc. I have an array, which describes the fields and...
5
by: nmtoan | last post by:
Hi, I could not find any answer to this simple question of mine. Suppose I have to write a program, the main parts of it are as follows: #include <blahblah.h> struct {
15
by: Alpha | last post by:
I was told that Unix API can only be called using C++, ATL and MFC. However, I was also told that C# can do that through Pinvoke to a DLL that interfaces with the Unix API. Can someone direct me...
12
by: Steve_Black | last post by:
I posted a similar message earlier but we've geared away from the original topic somewhat so I thought I'd post again in hopes of getting input from others. I am creating a MenuStrip...
4
by: max | last post by:
Hello, Based on various posts, I've come up with the following code to load data into a js array dynamically without a screen refresh. It works, but you have to push the button twice before it...
2
by: A.Wussow | last post by:
Hi Everybody, i want to load dynamically content from some user controls (with forms, or some data-controls) using atlas. So i use an UpdatePanel for loading the user control into a placeholder....
5
by: Amoril | last post by:
I've read quite a few different message on various boards and for some reason I'm still having trouble wrapping my head around this viewstate maintenance and trying to get these dynamically created...
7
by: mirandacascade | last post by:
Note: I'm not sure if the subject line of this post uses the correct terminology, so apologies if the subject line turns out to be misleading. I think it's probably easier to provide a trivial...
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
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: 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.