Reuse A Variable From Another Event?
Jul 30, 2011Dim conn As MySqlConnection Reuse a variable from another event?
View 3 RepliesDim conn As MySqlConnection Reuse a variable from another event?
View 3 Replies(using vb 2008 I am learning the workings of Custom Events. I think they might solve the problem of being unable to declare nonserialized events in vb2008. However, do custom events follow any sort of inheritance pattern like classes
View 4 Repliesi declared a global variable button:
Dim button1 As New Button()
Now, i dont know how to add a click event in this button since it is a variable.
Let's say I have two forms: Form1 and Form2.In form1 I have two buttons. btn1Frm1 opens Form2 As New Form2. btn2Frm1 opens Form2 as New Form2
View 3 RepliesI m new to VB. I have created a form with Menustrip and want to reuse this menustrip in other forms. Could anyone plz tell me how to do it ?
View 8 RepliesI have a form in a C# project that I started and now I want to use that same form design in a new VB project I'm starting. Is there a way to "export" the form from C# and import it into my VB project? Obviously, I don't want the C# code behind the form, just the design.
View 1 RepliesI am recently new to Visual Basic and am starting to learn some things i have managed to connect to the SQL Server and Insert rows to a table. But is there a way to be able to re-use an already existing connection ?My code below. I tried to create a class for the Connection object.
Imports System.Data.SqlClient
Imports System.Data.Sql
Public Class dbConnection
[code]....
I wanted to know if it is possible to reuse a class I created in one application in another application. Basically I created a test program and once I got all the components working I created a class for it and well I want to use the class in another program, how can I do this?
View 2 RepliesI designed a form - please see a picture My first intend was to "link" each button on the menu [Employee Management, Contact Information,...] to different forms by coping this form and then designing the contents of the form using many repeated following code
Dim oForm2 As New Form2()
oForm2.Show()
Me.Hide()
[code]....
I have this code
[Code]...
When I add an image to the imagelist, the con shows up. That's fine Let's say that I added 4 images (four items to the listview) then remove one item from the listview. From there, the next item I add will adopt the previous image added. How can I keep this from happening?
How can I tell something to use a code without completely adding it in that sub again? I have some code that will be used alot within my program. I could write a DLL, but I don't know how to use those!
Here is my code:
Dim str1 As String = System.IO.File.ReadAllText(Me.OpenFileDialog1.FileName)
Dim s2 As String = str1.Replace(".[1gs5]", "a")
s2 = s2.Replace(".[u775]", "b")
s2 = s2.Replace(".[fsef]", "c")
[Code]...
It is possible to buil un user control with a menu strip with this options (add record, delete, update) and reuse it in difrent forms?But, for example in form name "Cars" the option Delete must delete the cars currente record, but if im in form Buses, the same button wiil delete the bus record.
View 5 RepliesWhats the easiest way to reuse the content of my project ... e.g. Forms,UserControls. that will include all the required files ... e.g. resources,pictures
View 2 RepliesWhen I made the code in the sub generic and passed in the values the timer needed (hour, min, timername) from a start button it seems not to matter which start button is pressed as the labels output the information for the last button pressed.
View 1 RepliesOne of the VBF member was asking how to add a close button on the BindingNavigator control once and reuse it on all other forms, so I try to create a custom bindingnavigator class that inherits the BindingNavigator class.Below is the inherited class:
[Code]...
The thing that I can't figure out is that it looks OK in design mode, but at run time, the custom binding navigator shows 2 "Close" buttons. Only one of them will close the form when clicked, the other one doesn't function. See the attached image.
In my project i added a User Control so that i can reuse in different Windows forms.I designed and coded the UserControl1 according to my need and now i want to use it in Form2 but i cant understand how to do it?
View 2 RepliesI can't figure out how to make it so that when a variable reaches a certain value, an event is triggered. For example if I wanted a user's level to change to 2 when he gets 1000 exp.
Dim level as integer
Dim exp as integer
*****What do I put here?*****(when exp reaches 1000)
level = 2
I defined the following extension of the Date? data type
[Code]...
But when I moved my compiler definition to a separate DLL, I the ToObject method was no longer available from my project even though I had referenced the Class project which now contained the extension. Is this a limitation of the Compiler Extensions? HOw do you get reusability out of them?
I have an application that queries DHCP and pulls scope/subnet information. There are roughly 8k scopes on our network to query so reporting this data takes a little bit of time. I currently have this running on it's own thread and reporting to a progress bar so the applications doesn't seem inactive.
The DHCP api functions can report a total, a max read and a resume argument. This means that I can, in theory start 4 threads and have each thread read through 2k subnets, so it will only take 1/4 of the time to read all this data. Would I need to create four separate background worker handlers, do_works, runworkcomplete, report progress etc.?
If I have a string that contains the name of a control is there a way to call that control's click event?
Dim a as string = "MyButton1"
Now I want to call MyButton1.Click Method or MyButton_Click Event using the contents of a.
I'm moving from VB6 to VB.net and there are a few things confusing. In vb.net, your program just automatically has a form, now the form in in a class and so it may or may not be there. In vb6, the main subroutine controls program flow and I don't see that in vb.net. However, my biggest problem is that I have a com dll that has a connect class with events. I need to be able to access these variable outside of that class. I don't understand how to do that. I can't seem to declare public withevents outside of the class and in the namespace so it can be shared with other code. Its say "not valid" in Namespace.
So what is the best way to do that. Do I create a set/get property for the class that holds this value? And, if I do that, is the connect class automatically instantiated as a part of the COM dll? Right now I don't instantiate the connect class, I assume the application does. But I'm not sure exactly how the property of the class would be set...perhaps I would need to call the property set from the on-connection method. Anybody know what the answer to these two questions are and this 3rd one? How can I have a variable that has "events" have scope across the entire project?
I have a form in VB.NET that is used as a dialog in a mainform. Its instances are always locally defined, there's no field for it. When the user clicks the OK button in the dialog, it will fire an event with exactly one argument, an instance of one of my classes. Since it is always a local variable, how can I add an event handler for that event?
Code for the event, a field in MyDialog:
public Event ObjectCreated(ByRef newMyObject as MyObject)
Code for the main form to call dialog : (never mind the syntax)
Dim dialog As New MyDialog()
dialog.ShowDialog(Me)
AddHandler ObjectCreated, (what do I put here?) //Or how do I add a handler?
I can create event prodcedures for form objects, but is there a way to create an event that triggers when a certain variable equals a certain value?
View 3 RepliesI haven't quote grasped this whole "class" concept yet, but I'm working on it. When following the instructions below, the "test" portion of this code: "test.variable". It has an underlined error that says that "test" is not declared. If I remove the "test" word then the ".variable" shows not declared. I'm using Visual Studios 8 if that makes any difference. I have a pre-existing variable in a project that I would like to monitor for changes.
Re: Detect variable change.
Make your variable a class with an event.
Make your class:
VB.NET Syntax (Toggle Plain Text)
Public Class myVar
Private mValue As Integer
Public Event VariableChanged(ByVal mvalue As Integer)
[Code] .....
I'm trying to create a simple media player that will scan a directory for certain filetypes, add them to a playlist then play a random playlist entry - changing every x seconds.I figured this would be simple in VB and, to an extent it was. I have the code running that chooses the directory and plays the random file.I just need to now make this repeat every 30 seconds or so.I have all the coded attached under the sub for the 'open' function of the player so it's quite flat. I think I need to use a timer here, to trigger the routine to pick and play the media every 30 seconds?In doing this I think I need to break the variables out of the function I currently have as they need to be shared between the timer loop function and the central 'creating file list' function.
I'm having trouble - I'm no coder (as you'll tell!) and although getting this far was easy I'm now (I think) bumping into threading / variable scope issues which are a bit of a brick wall.I've tried making the variables public / global by declaring in the class rather than the sub but I get errors at runtime. Presumably because of how I'm creating the windows media objects? [code]
How can I make an event that is raised when a variable or property is changed (or can I just put the code I would put in an event in the Set section of a property?
View 5 RepliesHow could I create declaration(event) to a variable control in VB .net ? [code]please i need to know how to insert this (declaration) newweb_ DocumentCompleted it's similar to WebBrowser_DocumentCompleted but it's a variable
View 5 RepliesHow can i use a js variable in mouseOver event?Here is my code:
<script type="text/javascript">
window.String1 = <%=GetLocalResourceStringEscaped("String1")%>;
window.String2 = <%=GetLocalResourceStringEscaped("String2")%>;
[code].....
Im making a site in Visual Studio using vb and I have a variable in page_load but need its value in the event handler of a button for passing on session.
View 5 RepliesI'm wondering whether it is possible to declare a global variable in a click event. I need to declare an array of a specific size. The specific size is generated using a series of IF statements. I only need to know how to declare it.
View 1 Replies