开发者

identifiers in visual basic form

开发者 https://www.devze.com 2023-04-12 04:00 出处:网络
I have a form, user logs in and another form is generated. User submits a query. My problem is that I cannot keep a record of who is making the query.

I have a form, user logs in and another form is generated.

User submits a query. My problem is that I cannot keep a record of who is making the query.

The user has a uid and usernamae but once the new form is generated where the user submits the query both these identifiers are 开发者_运维技巧gone.

Is there a way in which I can overcome this? Thanks


If you're storing your UIDs only in the initial form, you'll need to pass in these values to the new form.

In essence, you could adjust your fields scopes and store your value in a place accessible by both forms, pass them into a constructor (and store accordingly), or provide an accessor in your new form to pass through the values you need.

To answer your question on the constructor:

Your code currently probably looks like the following:

Dim form2 as New Form2()
form2.Show()

You'll need to modify the constructor of the second form such as:

Public Sub New() ...

...should become...

Public Sub New(ByVal userId As String, ByVal userName As String) ...

And then pass in your values from the first form (where userId and userName are fields storing form1's values):

Dim form2 as New Form2(userId, userName)
form2.Show()

Then you could store them in your second form's global scope.


This is how I brought across the value into a new form. Seems like an easy fix, didnt realise it was so straightforward!

Dim val As String = CStr(Form1.ComboBox1.SelectedValue)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号