I have a couple of PUBLIC SUB's on my Form1. Is there a way that I can execute them on Form1 through another Form / Button-click? I am using a Dialog1.ShowDialog() for configuring some settings for my application. Now, I have most stuff on my Form1 set / loaded via PUBLIC SUB's (for example THEME SETTINGS, DROPDOWN LIST values and so on), and if I change something in the Dialog1 this Subs need to be executed again ...
Before my explanation gets too complicate, here a sample with a simple SUB:
Asume you have a Form1 with a Button1. On Button1Click a Dialog1.ShowDialog will be executed. In addition you have the following PUBLIC SUB on Form1:
Public Sub ShowMessage()
MessageBox.Show("Hello World!", "Message:", MessageBoxButtons.OK, MessageBoxIcon.Hand)
End Sub
How could I execute this Sub on Form1 from Dialog1 (maybe on a ButtonClick event)?
My plan is depending on the users screen resolution a different form will open. Thats all fine and works hunky dory.
However, the form pulls code from a public sub and updates fields on the form based from the public sub[code]...
My problem is how can I change the FORM1024x768 to say FORM1366x768 if the users screen resolution determines a different form is chosen. I need something like[code]...
I am attempting to make a form public. I've start out with this class:[code]I can see the stupid form thru intellisense, but when this code is run I'm getting a null reference exception. I believe this is because the stupid form has not been initialized. I thought that placing 'new' in my class definition would initialize the form.
I have a string on my main form called String1. When I open another form, I need access to this value. In the form I open, I have always done something like:Dim NewString as String = Main.String1
This has worked in the past. Well, I ended up renaming my forms (from Form1 to Main) in the property window and it now when I type the above code, it does not list Main as a form. Nothing that I renamed seems to exist now.
I have a Function for checking the input in a textbox and only allowing Numeric & Backspace; everything works fine so far. My form is for financials and it has about 20 textboxes; they all receive Numeric only data; there is NO alpha data on the entire form required. Note in the snippet below that I don't even need a decimal point as well.
Is there a way to handle ALL textboxes on this form without having to place the Function call in each textbox KeyPress event. took a long (5 year) hiatus from developing VB6
Public Function TrapKey(ByVal KCode As String) As Boolean If (KCode >= 48 And KCode <= 57) Or KCode = 8 Then TrapKey = False
I'm having trouble on calling a public sub on another form. Here is the sub: Public Sub BOTAO_NUMERICO(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles N0.Click, N1.Click, N2.Click, N3.Click, N4.Click, N5.Click, N6.Click, N7.Click, N8.Click, N9.Click Dim Res_ant As String Dim Res_atu As Double If (Res <> 0) Then [Code] .....
On form Normal, BOTAO_NUMERICO works fine, but on Cientifica it don't. OBS: All objects on both forms are the same, with same name.
I have a query setup on the start form in my project - it looks for a user level (1 or 2 right now) I want to display/hide items on the form based on whether or not the user's permission (derived from this query) is a 1 or 2.
My question is, can i create a public variable out of this query to use on any form until the application is quit?
The query will be formatted something like this:
Dim ssSQL As String = "SELECT UserLevel FROM [Employees] WHERE " ssSQL &=
I have public variables in a module. I need to get the reference of the variable by using the String name of variable in another formell me how to do this?I need something like the following code:
Dim Var1 As string Dim sVariableName As String = "Var1" GetReference(sVariableName).SetValue = "testing"
Just had a small doubt.Say i use something like this
vb Dim ownr as New Form1Dim Dlg as New Form2ownr.Showdlg.showdialog(ownr)
how should i call an public function of form1 in the form2 if form1 is owner of form2, and also if form1 is not the owner of form2 should i use FormName.FunctionName in both the cases.
I'm working on a project for my VB class at school. I am creating a form with several inputs and it calculates the total amount owed for a car sale. I have a text box for input of the TRADE IN VALUE of a car. the program is looking for a numeric input. If there is no trade in, how can i get this box to default to 0.00 so it doesnt error the program?
my problem is that i have an MDI Parent form. it has lots of child forms. on my MDI Form i have the toolbar buttons Add, Delete and Save.all or most of the child forms, i created a custom public procedure Sub AddNew, Sub Delete and Sub Save.what i'm trying to do is when i click the AddNew in the MDI Form, it will run the custom public Sub AddNew of the currently ActiveMDIForm. i have tried...
DirectCast(Me.ActiveMdiChild, Form2.AddNew() but i'm getting an error "Unable to cast object of type 'Form1' to type 'Form2'" if the currently ActiveMDIChild is not Form2.
I am writing a control application for an inteface card. The complicated work of initialising communication with the card is written and working fine. However, my problem is to update the text in a dialog label on the communication interface form from a module that contains all the coding for accessing the inteface card. From the module, the interface dll returns data that describes some typical connection errors and the module then calls on Public Subs in the form to display error messages; for example:This is the Public Sub in the Module that initiates communication with the interface card:
Public Sub OpenDeviceInterface() DeviceID = 1 - My.Resources.DeviceID h = OpenDevice(DeviceID) Select Case h Case 0, 1, 2, 3
[code]....
What happens when these Public subs are called from the module is that the MSgBoxes I made to test the routine show up but the label text doesn't appear.I've tried; Refresh, on the label and the form without success...
In vb.net, you can address a public variable from another form using the form name along with the variable.
form2.show form2.k = 3
However, if you use a form variable to show an instance of the form, you must use that variable name to address the public variable. Two instances of the same form are displayed in the following example. The public variable k is assigned a value of 3 only in the first instance of the form, the one from form2.show. frm.k can be used to assign a value to the other form.
dim frm as new form2 form2.show frm.show form2.k = 3
Assuming only one instance of the form is shown in the application, is it reliable to address a public variable using the form name (form2.k), or is it better to show the form with a form variable and use that to refer to the instance of the form (frm.k)? Would the same answer apply to a property as well as a public variable?
I am having a toolstrip in the mdi form which contains save, update delete and clear buttons. The child form is having save, update, delete and clear as public sub routines , and client form will not have any standard buttons, I will click the respective button in the parent tool window which should call the child forms function.
I have a Visual Basic form with a public sub procedure called xecute_Public_User_Defined_Sub_Procedure.I tried to call the sub procedure from the "ParentForm" below but could not.
Dim ParentForm As Form = CurrentTextBox.Parent If ParentForm IsNot Nothing Then ParentForm.Execute_Public_User_Defined_Sub_Procedure()
explain me the difference between them? I'm new to visual basic, and I need to know the very basic things in Visual Basic allowing me to become a professional User
Im having trouble with this code, when i had it working with static variables set, it was fine, now i am using a passed variable, its not working... Might not be anything to do with it, anyhow...
I have been playing around with VB for a while now, but still need to consolidate some thoughts. I was wondering if anyone could answer this..... Whats the difference between say Form1_Load and Public Sub New() on form startup? The reason i ask is i normally add calling subs to the form load process, but can you add any startup calls to the Public Sub New(), and if so, what is the advantage?