Transferring Variable From One Form To Another Form?
May 1, 2010I was able to pass my calculation from Form 1 to be used in another calculation in Form2.
Module1
Public ECC
As
[code].....
I was able to pass my calculation from Form 1 to be used in another calculation in Form2.
Module1
Public ECC
As
[code].....
QuoteImports System.Data.OleDb
Public Class admin
Inherits System.Windows.Forms.Form
Dim mypath = Application.StartupPath & "\db1.accdb"
Dim connection As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=d:\db1.accdb;Persist Security Info=False;")
[Code]...
So my question is that I have 2 list boxes in two forms aside from the main one. and I am trying to transfer what I choose in the side form to transfer to the list box.
several questions: Why does the blank list form I have in the main form create a problem when I enter a name for the list box and why does it appear in the box when I put it there? As you can see in my errors. It doesn't seem to recognize the listbox that I wanted to leave empty in the main form.
Second question is how do I get names to add in the main form list box. I believe I have the right code but I seem to be missing something else as well. I want the names to display in the main list box and the integers to add up together so I can separately figure the tax and shipping myself.
Here are some pictures and codes
Main:
Print:
Audio:
Public Class MainForm
Dim frmAudioBooks As New AudioBooks
Dim frmPrintedBooks As New PrintedBooks
[Code].....
The first form in my project is a simple form for a shop selling cars. At the end of the form is a text box called txtTotal.text, this is the total cost of each sale. When I press the print button I not only want to print a sales invoice(I have that bit done) but I also want the total in txtTotal.text to be added to lblDaysTakings on my second form called frmAudit. Ive searched the web far and wide and cant find anything either suitable or within my level of understanding.
Ive tried code such as
Private Sub cmdPrint_Click()
Dim curTotal As Currency
Dim curDaysTakings As Currency
[code]....
and several other combinations but Im obviously a mile and a half off track as Im not getting anywhere?s a lot bigger than just the print button but I didnt see the point in posting the rest as I have everything else sorted out, its just transfering the numbers from one form to the other thats getting me.
Im having a problem when transfering values from form to form.Firstly I have a main menu form,click on a button to go to the dell components form.I choose the components for the computer and when i hit calculate the total is displayed in a textbox for my subtotal. When i press send it will send the sub total from the dell components form to the grand total and display it in the dell sub total in the grand total form.This part works ok, however, i go to the main menu and click on a button to go to the packardbell components form. Do the same again but when i press send, it will send the value to the grand total form in the packardbell sub total textbox but the value in the dell sub total textbox has vanished.Here is the code in the dell components form
Code:
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
Dim frm As frmGrandTotal = New frmGrandTotal(txtDellSubTotal.Text)
Me.Hide()[code].....
Finally, the other problem im having is on the main menu form when I click on the view total button I get this error: Here is the code for this bit
Code:
Private Sub btnViewTotal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnViewTotal.Click
'frmGrandTotal.Show()
Me.Hide()
End Sub
How do you pass one radiobutton from form 2 to form 3? Iv tried:
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Form2.rbtnPatterned.Checked = True Then
rbtnPatterned.Show()
End If
But that doesn't work. The radiobutton selected in form 1 doesn't appear in form 2....
I m working with a appliction in VB.net
I have a three forms .Menu form which i have set IsMdiContainer as true
Through this form I m opening a new form named " Query"
This form has two drop down and one textbox and some other controls
When user selects ths first dropdown (States)second gets filled with City
When use selects a city I wat to open a New form named as parameter.parameter
form has two textbox and user will enter the paramater and click the submit button.
I want the text of these two textboxes in My "Query" forms 's text box and I want the drop down as it is(filled with city and states)
I'm taking my first (and only) beginning programing class for Visual Basics 2008. I'm working on my final project and have hit a snag. A little background info - I have been able to code everything except for two final steps (but they are my most difficult steps), on these final steps I've gotten two suggestions on other sites, one person helped me with the coding which I used for my form1, but it I still have several errors, and another person suggested that I use a module.
Here is the issue. I have totals on three forms that need to pass through to a final form, and once they are on the final form they need to show up in an itemized list and need to then be totaled again. I actually have a total of 5 forms including my first form aptly named form1, which incidentally is where someone told me I should set up my whole 'connecting the totals' form, and I believe the guy was on the right path with helping me but, I'm still obviously pretty lost on this last segment of coding. Since I had little difficulty with the majority of my project, I didn't think this last bit would be so difficult. I'm going to list my coding for each form below. My project is due Tue morning May 5th Eastern Standard Time, just in case someone starts reading this on or after that date. Just in case it helps explain the issue, I will also post my listing of error codes from my VB project, and they all are centered around my form1 (which is the form that I'm trying to set up the transfer through of the form totals). I also see that I can post attachments so in case it will help I'm going to post my project in the attachment too.
Error Codes:
Error1Event 'Load' cannot be found.
Error2Handles clause requires a WithEvents variable defined in the containing type or one of its base types.
[Code].....
I created a VBA project in Excel. I would like to figure out how to transfer the data back in forth to make a more presentable and user-friendly program in VB Studio.Basically, I need my form in VB to input data to into an excel �workbook.data�, where the calculations are preformed. Then I need to copy the finished excel data cells �workbook.results� and paste them into an end result form in VB. I have tried looking at threads and cannot come up with a solution. There is no data saved each time the program runs, so I don't have a database.
View 14 RepliesI have one form, which the user enters upto 5 websites then clicks go - I have on the second form, the one with the webbrowser. timer which checks if the web browser is busy then either a green light or black image will be shown along side the assocaited input box on the first form. I am finding it impossible to feed variables into the clock through ByVal, like I would a subroutine or function.
[Code]...
Is it possible to pass a variable set in one form to another?
View 12 RepliesIf I make the following array in a push button event and I want to put those array variables in a class array. How do I do that? I am just beginning to learn about classes in vb.net but I am having problems using classes and arrays.Is there any good tutorials on that subject.
[Code]...
Using Visual Basic 2008 Express. I need to pass a variable to another form. Or else make the variable visible to both forms.
View 4 RepliesSay I set a variable on form1 like this:
Dim thisVariable as String
Then I want to use it on form2. How can I do that?
I have this on my main window
vb.net Public GameDate As New DateTime(1970, 1, 1)
And upon a button click I create a new instance of another form in my project.
[Code]...
I'm making a VB app which has two forms, a main form, and an options menu. How can I take a integer variable from one form (the options form) to the main form. I have tried one or two ways, but so far, nothing.
View 10 RepliesIn my application, I have two forms, and two corresponding *.vb files for the source code of the forms.I have a string of arrays in the main form declared in it's .vb file. The other form, I want to make it fill that array.I tried the "Public strVar(0 to 99) As String", but even with that my other form's .vb file does not recognize it. how do I declare a variable that can be used by all forms?
View 4 Repliesi am currently trying to re-write an old VB6 program into .net basically the program contains 100's of forms for different jobs each with a Public Sub runjob(). the form names are then stored on a database. the user then selects the job from the listbox and it calls the correct job.the code i use to use in vb6 was
sValue = database.rsselectjobrun.Fields("callname")
Set frmName = Forms.Add(sValue)
frmName.runjob
Set frmName = Nothing i have looked into it and found this code which calls the form in .net
Dim objForm As Form
Dim sValue As String
Dim FullTypeName As String
[code]....
but i cannot get this to run anything other then the formload code. i know i can put all of this into a select case module but id rather not with the amount of forms i would have.
I have declared this variable in a module : Public GenericForm As System.Windows.Forms.Form
and then through code I can asign to that variable a specific form .For example GenericForm = Form1. Then I can use that variable to handle that specific form , for example :
GenericForm.Show
My problem begins when I want to handle a control on that form , for example :
GenericForm.TextBox1.Text = "aaa"
This code creates an error reading :TextBox1 is not a member of System.Windows.Forms.Form.I have been using code like this in VB6 and was quite useful ,but now in VB .NET I cannot .You see I have many forms on which there are some text boxes with the same name,so I declare a generic variable as Form and accordingly insert the code the desired text box conform the form I wish each time . Can I do this in VB .NET too ?
I know in VBA you could pass an entire form as a varible. Since using global variables are not advised in .net 2008, is there anyway to do this ?
View 9 RepliesI am upgrading a very large project from VB6 to VS2008. I have several forms with dozens of combo boxes on each form. I use the same combo box names for each form and want to fill them from a module with different items depending upon the calling form. In VB6, I dimensioned a public variable - FormName as object and called Set FormName = frmMyForm1 on Form Load. In a module, I was able to write the following code:
With FormName
.combobox1.additem("item")
.combobox2.additem("item"
End With
I cannot make this work in VB.Net. When the form loads I call FormName = Me. If I dimension Friend FormName as Object, I get the error message that Public member combobox1 on type MyForm1 not found. If you are attempting to access members on a late-bound object make sure it is declared public". If I dimension Friend FormName as Form, I get an error that says "combobox1 is not a member of System.Windows.Forms.Form".
I have tried both CType and DirectCast to convert the form variable from Object to Form with no success. I also tried creating a public array and storing each form name in it.
How Do I Transfer A Variable From One Form To Another? I'm trying to transfer an integer variable and an array of string from my main form to my other form, how do I do it? So far I've been trying with functions but it won't work here's my code for the first form: [Code]
View 1 RepliesI want to transfr the values of 1 variable to another form i have tried declaring it public in module and still its getting the value 0.. my code is similar to this one..i have a variable mult in form 1 and it is storing the value of a * b a and b are getting values form user through text box..
mult = a * b
now i want the value of mult in form 2..
Is it possible to use a Variable that reside on another Form?
View 5 RepliesI have two forms and I need to take the values from the first form and add them to the second form. I have tried many things and nothing is being added or changed yet on the second form. The second form has a Panel as a background, then a GroupBox to group items together and then the relevant controls themselves. I have been working at this for the last few hours and not getting anywhere and needs a second pair of eyes.
I have tried DirectCast() and it doesnt work. Nothing happens. The data isnt added or the control selection isnt changed. No errors either. I have tried Me.ControlName.Property = FormName.ControlName.Property and it doesn't work. Nothing happens. The data isnt added or the control selection isnt changed. No errors either. [Code]
I have two forms and I need to take the values from the first form and add them to the second form. I have tried many things and nothing is being added or changed yet on the second form. The second form has a Panel as a background, then a GroupBox to group items together and then the relevant controls themselves.I have been working at this for the last few hours and not getting anywhere and needs a second pair of eyes.I have tried DirectCast() and it doesnt work. Nothing happens.The data isnt added or the control selection isnt changed. No errors either.I have tried Me.ControlName.Property =FormName.ControlName.Property and it doesnt work. Nothing happens. The data isnt added or the control selection isnt changed. No errors either.Screen shots attached and so is my code.Button Click
vb
Private Sub cmdStartClientSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdStartWorkLogEntry.Click
[code]......
I have an apllication with many many distinct forms.
So, I need sometimes open a form, wich the name is strored in one variable
For example I have this:
dim aaa as string
aaa="frmTestForm"
I wanna open the form who have the name keepted in aaa.
Something like this:
[aaa].show()
I have datagrid in which the 0th column has ID. What i want is while clicking on the datagrid the id of the particular row has to be load in the variable in the second form. For this i have created a public variable in the second form [code]but here its not returning any value to EditID while loading the second form.
View 1 RepliesIs there any method or a way to copy a form object to a variable? Let me explain this - We have a method called "Copy" for the Dataset class & you all must be knowing that there is a difference between the below two lines of code: DsTemp = Ds DsTemp = Ds.Copy()
In the first line of code, any changes made to Ds will reflect in DsTemp. However, in the second line of code, any changes made to Ds will not reflect in DsTemp because we are only "copying" the contents & schema of Ds. Likewise is there a method or a work around to "copy" a Form object?
[Code]...
I am building a generic search form in my application. This will allow the user to search for various records throughout the application. The one thing I cannot seem to figure out is how to allow the declaration of the TableAdapter to change at run-time. Each part of the app will be passing a variable to the search form to specify which table should be loaded. In the form class I have the following:
FRIEND WITHEVENTS tbaSearchData AS database.databaseTableAdapters.TableOneTableAdapter This is great for TableOne. But, I have about a hundred tables that could be searched through. To load the data I'm using a DataGridView and populating it via a private method.