Call A Form By String Reference?
May 16, 2012I am trying to open form using a string reference in loop.
Dim XXX As Integer
Dim slideName As String = Nothing
Dim slideNameX As String = Nothing
[code]....
I am trying to open form using a string reference in loop.
Dim XXX As Integer
Dim slideName As String = Nothing
Dim slideNameX As String = Nothing
[code]....
I need to call a form from a string inside a dll. I write the following code. The form was shows but the control on the form was not diplayed.
Private Sub tv_main_AfterSelect(sender As System.Object, e As System.Windows.Forms.TreeViewEventArgs) Handles tv_main.AfterSelect
Dim strQuery As String
[Code].....
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"
[code].....
i need to call mdi form toolstripmenuitem name using the string variable. for ex, mdi form is Form1. toolstripmenuitem is customer master if i do like that "Form1.customer master.Enabled=True" its working
but my issue is i stored customer master in a string variable like mystring="customer master" i need to enabled using the string variable like Form1.mystring.enabled=True
My problem is when i try to call Application.Run() in a application without a form i get "Object reference not set to an instance of an object." when i run it outside VS. but if ran in debug or release mode it works just fine. i may just be forgetting to setup application right, but ive done it before in this same manor and it worked fine.
Sub main() 'this runs first.
AddHandler Application.ApplicationExit, AddressOf ExitEventHandler
dbg_f("handle added")
[CODE]...
Commented out init_timer and init_ready, and now it causes the same error for the myName line. there seems to be something wrong with class Application. btw theres seems to be something wrong with the forum code formatting.
I have a VB .NET 2010 application. I added a C# project to my solution. I tried to call the form called 'main'. However, I could not figure out a way to do that. What is the best way to do that? I Goggled, and did not find anything. Actually I noticed that my Developer converted everything to VB .NET.
View 5 RepliesI have a class file framebuild with a class command and class commandlist(of command). I fill the comandlist with a method in the class commandlist, to do that I make in the class commandlist a new instance of commandlist. But now in form4 I want to make a listbox which represents the commandlist. Then I also should make a new instance of a new instance? It is no problem to fill the list in the class instance but I want to fill it in the form.vb
Public Class rts485command
Property name As String = ""
Property hexname As Byte = &H0
Property framelength As Byte = &H0
End Class
[Code] .....
So strings are reference types right? My understanding is a reference to the string in the heap is passed even when you pass the string ByVal to a method.
String myTestValue = "NotModified";
TestMethod(myTestValue);
System.Diagnostics.Debug.Write(myTestValue); /* myTestValue = "NotModified" WTF? *[code].....
And what is going on under the hood? I would have bet my life that the value would have changed....
I have written my own function, which in C would be declared like this, using standard Win32 calling conventions:int Thing( char * command, char * buffer, int * BufSize);I have the following amount of VB figured out, which should import the dll and call this function, wrapping it up to make it easy to call Thing("CommandHere",GetDataBackHere).UPDATE:This code is now a working solution, as shown here:
Imports Microsoft.VisualBasic
Imports System.Runtime.InteropServices
Imports System
Imports System.Text
[Code]...
Updates: I got the code to build by following the help received here, and then I had forgot the As Return Type (which got me a MarshalDirectiveException PInvokeRestriction). Then I had an assertion failure inside my DLL, which lead to an SEHException. Once fixed, this works BEAUTIFULLY. There are newsgroups where people are saying this can not be done, that VB only loads managed dll assemblies (which I guess is the normal thing most VB users are used to).
I have two forms. Form A and Form B. Form A has a datagrid that is populated from a SQL Database Table query. When a button is pressed Form B is launched that allows you to add a record to the database table. I need for the datagrid to be refreshed and show the newly added record when I close form B and go back to the parent.
[Code]...
I need to know the proper way, or maybe I should say, the different ways to call another form from a parent or preceding form. I am currently using ex: formname.showdialog() to call my next form, but I am uncertain if I should be using that in every situation. [code] Whats the difference between these different methods? (ex: .showdialog() , .show() )I tried both of these to open a temporary form to retrieve a persons name from a database, so as the users progresses through my training program they can keep track of their scores.But, I also call other forms as I branch through my program, from the main page, to a secondary page, to a testing page, to a results page and then back to the secondary page
View 5 RepliesHow can I disable the parent form when I call a child form?This code doesn't disable the parent form like I thought it would:
frmChild.ShowDialog()
I am trying to program a dialogue box to appear when the exit button from my 'Login' form is clicked. The form has three options; yes, no, cancel.
[Code]...
I have a small program which draws some lines with a method called: Drawlines But Now I want to call this method in the load form routine. So if the form is loaded the lines should be drawn in the picturebox. But is this possible or should the form first be loaded completely before you can call methods in that same form?
View 6 RepliesCould i call the child form events like (closing ,load, activate,closed) .
View 6 RepliesI have two form :
class form1 'parent form dim number as integer
public sub create ()
dim f2 as new form2
f2.MdiParent = me[code]....
In form2.vb how to use variable number and method test
I have database with class names listed in string field. I want to circle thru records and call certain class.
Eg.
Data table
ID ClassName
1 ClsCreateButton
2 ClsCreatePanel
After retriving this data in dataset(ds.tblClass) I want to do next:
Dim aClass as New ds.tblClass("ClassName")
Do something with aClass...
Is it possible to call a sub with a string.vb Dim subname as stringsubname = textbox1.text(Code for calling sub, subname)
View 5 RepliesTo simplify my problem, lets say I have 200 textboxes on a form. I want the first 100 to become disabled in a certain subroutine. I don't want to write 100 lines to disable each textbox; I'd rather write a loop to do it but can't figure out how. For instance:
dim i as integer
dim s as string
for i = 1 to 100
[Code].....
I tried "dim c as new control" then "c.name=s" but I don't think this makes "c" as a member of my form and it didn't do anything as a result. I think I need to figure out how to declare c as a control that exists within my form but can't figure out the syntax for that.
I was wondering what is the ideal way to reference a connection string.I'm using Visual Studio 2008.I am new to VB.NET and I inherited this piece of software from another developer.
He currently uses a class (shown below) that is not part of the entire Solution, but is saved as a .dll file called clsDBConn and is located in the Reference folder in the Solution Explorer. This seems like a long way to access a connection string,
Is this the ideal way to access a connection string?[cod]e...
I have a form with about 750 buttons and i want to be able to refer to a button based on a string.
For example, instead of writing...
Button1_A.BackColor = Color.ForestGreen
I want to write...
Dim Q_No As String
Dim Btn_Type As String
Dim Btn As String
[Code]....
But i just get the error message "'BackColor' is not a member of 'String'"
I have to use Form.Action to redirect to a script that will be picking up values from my page. It is worth noting that this script is external.My issue is that I also want the button that is clicked and has the Action hooked up to it, to also complete some functionality in the code behind first.Is there anyway I can either :In the buttons click event handler, can I set the Form.Action and then call something such as Form.Submit?OR Set up the Form.Action in advance and then somehow have the button posting back before the action takes place.
View 5 RepliesI have one form called invoiice1.vb In the load event how can i call another form ? I also call some values of thatt form
View 2 RepliesI have a sub declared inside a module which accepts form as argument.
sub display(fname as form)
What I need is to call the sub form the load event of a form. I tried the following.
display(me)
But cant access the controls of the form inside the sub.
sub display(fname as form)
fname. 'no controls of the form are listed?????????????
end sub
I added toolstrip control into MDI form. on the parent form, creat many toolstripbutton like tbAdd, tbSave,tbEdit.When I open child form, how to call tbAdd or tbSave.. toolstripbutton on the MDI?
View 1 RepliesMy app has a main form (it's the startup form). It includes a number of menu items which typically open modal sub forms. However there are 2 menu items which just need to open an Outlook Explorer calendar for the user to manipulate appointments. My VB6 version used hidden sub forms to do this and handle the subsequent interaction between the user and the Outlook objects in the Calendar. I need to stop the user interacting with the main form while the Outlook Explorer is open, ie as if the Explorer window were a modal sub-form to the main form. So I manually disable the main form while the Outlook activity is going on, then (try to) enable it when the user closes the Outlook Explorer window. Problem is I can't seem to get a reference to the main form from the sub form to do this, nor pick up an event in the main form which I could use to trigger the enabling of the main form.An alternative might be to delete the hidden sub forms & put all the code in the main form, but this would be quite ugly; I think I would need to maintain two parallel sets of Outlook objects at the top level in the main form for each of the two functions (a number of the Outlook objects are declared With Events). I would have to have for example mobjOutlookExplorerFunction1 and mobjOutlookExplorerFunction2.
View 5 RepliesIs it possible to recall a string or object that was stored in a previous sub? The below code gives you an idea as to what I am trying to do.
Sub StoreUserData()
Dim StorName as Object
End
Sub WriteUserFile()
'Recall StorName here
End Sub
My application has a variable VAR_1 that is boolean, this name is also stored in database.
Now I need to set VAR_1 value in my app by reading database and asign x value,
How do I call VAL_1 from a string?, this is:
Dim VAL_1 as boolean
Dim str as string = myTable.Rows(0).item("x") <--- Here's the name "VAL_1"
But I just can't find how to call VAL_1 by converting "VAL_1" to variable
This is probably a dumb question but I have to call one of 30 or so global variables by constructing the variable name to be called from another information. However when i do that it treats it as a string. Any ideas on how to make this work?eg something like this:
Public gsNewYork As String
public sub Getinfo
dim lslocation as string
[code].....
Is it possible to read a string and call the method of the same name?For example: I have many buttons and if the user presses the button named A1, I want the Sub AI() to be called. I don't want to do an explicit If-Then for each button. Rather a common ONCLICK method that is called by all buttons and another method (the same name as the name of the button) is called.
Example:
Sub Click(byVal buttonName as string)
call ButtonName ' <<<< Error. ButtonName is string and not a Method.
End Sub