472,958 Members | 2,363 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

How do I add check box items from one form to a list box on another

I am having trouble with this Skateboard designer program, and I am not sure how to add items from a separate form to a list box on the main one. Any help at all would be very appreciated.

Here's my code so far:

Expand|Select|Wrap|Line Numbers
  1. Public Class MainForm
  2.     Private Sub btnReset_Click(sender As Object, e As EventArgs) Handles btnReset.Click
  3.         lblDeck.Text = String.Empty
  4.         lblTrucks.Text = String.Empty
  5.         lblWheels.Text = String.Empty
  6.         lblSubtotal.Text = String.Empty
  7.         lblTax.Text = String.Empty
  8.         lblTotal.Text = String.Empty
  9.     End Sub
  10.  
  11.     Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
  12.         Me.Close()
  13.     End Sub
  14.  
  15.     Private Sub btnClearMisc_Click(sender As Object, e As EventArgs) Handles btnClearMisc.Click
  16.         lstMisc.Items.Clear()
  17.     End Sub
  18.  
  19.     Private Sub btnViewDecks_Click(sender As Object, e As EventArgs) Handles btnViewDecks.Click
  20.         frmDecks.ShowDialog()
  21.     End Sub
  22.  
  23.     Private Sub btnViewTrucks_Click(sender As Object, e As EventArgs) Handles btnViewTrucks.Click
  24.         frmTrucks.ShowDialog()
  25.     End Sub
  26.  
  27.     Private Sub btnViewWheels_Click(sender As Object, e As EventArgs) Handles btnViewWheels.Click
  28.         frmWheels.ShowDialog()
  29.     End Sub
  30.  
  31.     Private Sub btnViewMisc_Click(sender As Object, e As EventArgs) Handles btnViewMisc.Click
  32.         frmMisc.ShowDialog()
  33.     End Sub
  34.  
  35.     Private Sub MainForm_Activated(sender As Object, e As EventArgs) Handles Me.Activated
  36.         lstMisc.Items.Add(intMisc1)
  37.         lstMisc.Items.Add(intMisc2)
  38.         lstMisc.Items.Add(intMisc3)
  39.         lstMisc.Items.Add(intMisc4)
  40.         lstMisc.Items.Add(intMisc5)
  41.     End Sub
  42. End Class
Expand|Select|Wrap|Line Numbers
  1. Module ChargesModule
  2.  
  3.     ' Global constants
  4.     Public frmDecks As New DecksForm
  5.     Public frmMain As New MainForm
  6.     Public frmMisc As New MiscForm
  7.     Public frmTrucks As New TrucksForm
  8.     Public frmWheels As New WheelsForm
  9.     Public dblDeck As Double
  10.     Public dblTrucks As Double
  11.     Public dblWheels As Double
  12.     Public dblMisc As Double
  13.     Public dblSubtotal As Double
  14.     Public dblTax As Double
  15.     Public dblTotal As Double
  16.     Public int51mm As Integer = 0
  17.     Public int55mm As Integer = 1
  18.     Public int58mm As Integer = 2
  19.     Public int61mm As Integer = 3
  20.     Public dbl51mm As Double = 20
  21.     Public dbl55mm As Double = 22
  22.     Public dbl58mm As Double = 24
  23.     Public dbl61mm As Double = 28
  24.     Public intAxle1 As Integer = 0
  25.     Public intAxle2 As Integer = 1
  26.     Public intAxle3 As Integer = 2
  27.     Public dblAxle1 As Double = 35
  28.     Public dblAxle2 As Double = 40
  29.     Public dblAxle3 As Double = 45
  30.     Public intDeck1 As Integer = 0
  31.     Public intDeck2 As Integer = 1
  32.     Public intDeck3 As Integer = 2
  33.     Public dblMasterThrasher As Double = 60
  34.     Public dblDictatorOfGrind As Double = 45
  35.     Public dblStreetKing As Double = 50
  36.     Public dblGripTape As Double = 10
  37.     Public dblBearings As Double = 30
  38.     Public dblRiserPads As Double = 2
  39.     Public dblNutsAndBoltsKit As Double = 3
  40.     Public dblAssembly As Double = 10
  41.     Public intMisc1 As Integer
  42.     Public intMisc2 As Integer
  43.     Public intMisc3 As Integer
  44.     Public intMisc4 As Integer
  45.     Public intMisc5 As Integer
  46.     Public intGripTape As Integer
  47.     Public intBearings As Integer
  48.     Public intRiserPads As Integer
  49.     Public intNutsAndBoltsKit As Integer
  50.     Public intAssembly As Integer
  51. End Module
Expand|Select|Wrap|Line Numbers
  1. Public Class MiscForm
  2.     Private Sub btnAdd_Click(sender As Object, e As EventArgs)
  3.  
  4.         If chkGripTape.Checked = True Then
  5.             dblMisc += dblGripTape
  6.             intMisc1 = CInt(chkGripTape.Text)
  7.         End If
  8.  
  9.         If chkBearings.Checked = True Then
  10.             dblMisc += dblBearings
  11.             intMisc1 = CInt(chkBearings.Text)
  12.         ElseIf intMisc1 = intGripTape Then
  13.             dblMisc += dblBearings
  14.             intMisc2 = CInt(chkBearings.Text)
  15.         End If
  16.  
  17.         If chkRiserPads.Checked = True Then
  18.             dblMisc += dblRiserPads
  19.             intMisc1 = CInt(chkRiserPads.Text)
  20.         ElseIf intMisc1 = intBearings Then
  21.             dblMisc += dblRiserPads
  22.             intMisc2 = CInt(chkRiserPads.Text)
  23.         ElseIf intMisc1 = intGripTape Then
  24.             dblMisc += dblRiserPads
  25.             intMisc2 = CInt(chkRiserPads.Text)
  26.         ElseIf intMisc1 = intGripTape And intMisc2 = intBearings Then
  27.             dblMisc += dblRiserPads
  28.             intMisc3 = CInt(chkRiserPads.Text)
  29.         End If
  30.  
  31.         If chkNutsAndBoltsKit.Checked = True Then
  32.             dblMisc += dblNutsAndBoltsKit
  33.             intMisc1 = CInt(chkNutsAndBoltsKit.Text)
  34.         ElseIf intMisc1 = intBearings Then
  35.             dblMisc += dblNutsAndBoltsKit
  36.             intMisc2 = CInt(chkNutsAndBoltsKit.Text)
  37.         ElseIf intMisc1 = intGripTape Then
  38.             dblMisc += dblNutsAndBoltsKit
  39.             intMisc2 = CInt(chkNutsAndBoltsKit.Text)
  40.         ElseIf intMisc1 = intRiserPads Then
  41.             dblMisc += dblNutsAndBoltsKit
  42.             intMisc2 = CInt(chkNutsAndBoltsKit.Text)
  43.         ElseIf intMisc1 = intGripTape And intMisc2 = intBearings Then
  44.             dblMisc += dblNutsAndBoltsKit
  45.             intMisc3 = CInt(chkNutsAndBoltsKit.Text)
  46.         ElseIf intMisc1 = intGripTape And intMisc2 = intRiserPads Then
  47.             dblMisc += dblNutsAndBoltsKit
  48.             intMisc3 = CInt(chkNutsAndBoltsKit.Text)
  49.         ElseIf intMisc1 = intBearings And intMisc2 = intRiserPads Then
  50.             dblMisc += dblNutsAndBoltsKit
  51.             intMisc3 = CInt(chkNutsAndBoltsKit.Text)
  52.         ElseIf intMisc1 = intGripTape And intMisc2 = intBearings And intMisc3 = intRiserPads Then
  53.             dblMisc += dblNutsAndBoltsKit
  54.             intMisc4 = CInt(chkNutsAndBoltsKit.Text)
  55.         End If
  56.  
  57.         If chkAssembly.Checked = True Then
  58.             dblMisc += dblAssembly
  59.             intMisc1 = CInt(chkAssembly.Text)
  60.         ElseIf intMisc1 = intBearings Then
  61.             dblMisc += dblAssembly
  62.             intMisc2 = CInt(chkAssembly.Text)
  63.         ElseIf intMisc1 = intGripTape Then
  64.             dblMisc += dblAssembly
  65.             intMisc2 = CInt(chkAssembly.Text)
  66.         ElseIf intMisc1 = intRiserPads Then
  67.             dblMisc += dblAssembly
  68.             intMisc2 = CInt(chkAssembly.Text)
  69.         ElseIf intMisc1 = intNutsAndBoltsKit Then
  70.             dblMisc += dblAssembly
  71.             intMisc2 = CInt(chkAssembly.Text)
  72.         ElseIf intMisc1 = intGripTape And intMisc2 = intBearings Then
  73.             dblMisc += dblAssembly
  74.             intMisc3 = CInt(chkAssembly.Text)
  75.         ElseIf intMisc1 = intGripTape And intMisc2 = intRiserPads Then
  76.             dblMisc += dblAssembly
  77.             intMisc3 = CInt(chkAssembly.Text)
  78.         ElseIf intMisc1 = intBearings And intMisc2 = intRiserPads Then
  79.             dblMisc += dblAssembly
  80.             intMisc3 = CInt(chkAssembly.Text)
  81.         ElseIf intMisc1 = intGripTape And intMisc2 = intNutsAndBoltsKit Then
  82.             dblMisc += dblAssembly
  83.             intMisc3 = CInt(chkAssembly.Text)
  84.         ElseIf intMisc1 = intBearings And intMisc2 = intNutsAndBoltsKit Then
  85.             dblMisc += dblAssembly
  86.             intMisc3 = CInt(chkAssembly.Text)
  87.         ElseIf intMisc1 = intRiserPads And intMisc2 = intNutsAndBoltsKit Then
  88.             dblMisc += dblAssembly
  89.             intMisc3 = CInt(chkAssembly.Text)
  90.         ElseIf intMisc1 = intGripTape And intMisc2 = intBearings And intMisc3 = intRiserPads Then
  91.             dblMisc += dblAssembly
  92.             intMisc4 = CInt(chkAssembly.Text)
  93.         ElseIf intMisc1 = intGripTape And intMisc2 = intBearings And intMisc3 = intNutsAndBoltsKit Then
  94.             dblMisc += dblAssembly
  95.             intMisc4 = CInt(chkAssembly.Text)
  96.         ElseIf intMisc1 = intGripTape And intMisc2 = intRiserPads And intMisc3 = intNutsAndBoltsKit Then
  97.             dblMisc += dblAssembly
  98.             intMisc4 = CInt(chkAssembly.Text)
  99.         ElseIf intMisc1 = intBearings And intMisc2 = intRiserPads And intMisc3 = intNutsAndBoltsKit Then
  100.             dblMisc += dblAssembly
  101.             intMisc4 = CInt(chkAssembly.Text)
  102.         ElseIf intMisc1 = intGripTape And intMisc2 = intBearings And intMisc3 = intRiserPads And intMisc4 = intNutsAndBoltsKit Then
  103.             dblMisc += dblAssembly
  104.             intMisc5 = CInt(chkAssembly.Text)
  105.         End If
  106.     End Sub
  107. End Class
Feb 7 '20 #1
3 2935
Luk3r
300 256MB
You just need to explicitly specify the additional form name before the array or variable.
Expand|Select|Wrap|Line Numbers
  1. lstMisc.Items.Add(MiscForm.intMisc1)
Also worth noting is that some of the ElseIf statements on your MiscForm will never be hit because the former criteria will be matched every time. In the example below, the latter should be moved above the former.

Expand|Select|Wrap|Line Numbers
  1.          ElseIf intMisc1 = intGripTape And intMisc2 = intBearings Then
  2.              dblMisc += dblNutsAndBoltsKit
  3.              intMisc3 = CInt(chkNutsAndBoltsKit.Text)
  4.  
  5.          ElseIf intMisc1 = intGripTape And intMisc2 = intBearings And intMisc3 = intRiserPads Then
  6.              dblMisc += dblNutsAndBoltsKit
  7.              intMisc4 = CInt(chkNutsAndBoltsKit.Text)
  8.  
Feb 11 '20 #2
rollerbladegirl
69 64KB
Is that in .net?

It has been a while since I programmed in visual basic 4 / 5 / 6, but I do not remember stuff like
lstMisc.Items.Add
except if the lstMisc was a name of a form.

Shouldn't the post be moved to the .NET forum?
Feb 14 '20 #3
All you have to do is make reference to the destination form.
Lets say
Expand|Select|Wrap|Line Numbers
  1. Form2.ListBox1.Items.Add(Me.CheckBox1.Text)
  2.  
  3.  
Please give feedback
Jul 22 '20 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: M. Clift | last post by:
Hi All, This would seem to be easy, but I have had no luck in working out how to do this. In wx.python a list of text is displayed as a bitmap and given it's position. shape.pos = (145,...
4
by: tom | last post by:
Hi Experts, I want to pass the selectedDate value from my calender form to another web form or a web user control. Could you please show me how to do this? Thanks in advance.
4
by: Gene | last post by:
As my purpose is to load one form at a time, so I want to unload another form before loading the form. But how to check which form is being load, so I can unload it first.
2
by: PM | last post by:
I have a VB.NET question about ListViews and Forms. I have a listview with records. I want a user to be able to double-click on a record, and have a subform come up with detailed information...
0
by: nikefido | last post by:
Hi, I am programming using VS2005, creating a windows application (Using visual basic). I'll attempt to keep this simple: We have on Form1 a listbox populating froma column in a datatable. We...
1
by: MayhemMickells | last post by:
Alright soo, I'm working on this program for my programming class using VB 2005 and it's driving me insane. See the program is like this. The main form has a list box for selected products and...
2
by: ramya naidu | last post by:
Hai iam working with list and i have added items to list and how can i find whether the items are added to list or not using windows applications using c# and how can i display the items in list in...
1
by: menyki | last post by:
am still finding it difficult as a new java user. am designing a software that has multiple forms, controls such as combobox and so on and finding it difficult to do the following. i want some...
5
by: Aaitaman Tamang | last post by:
Hi everybody, I have two listbox in my form, the name of listbox is “ListBox1” and another is “ListBox2”. The ListBox1 Row Source Type is (Table/Query) where users will see all the employee Badge...
3
by: ashleybeck | last post by:
Hello! I have a multiple value form: sbfrmTests_multi *Please ignore sbfrm - at present that is the name, but it has no parent. - Form use: select tests and insert them into a template with...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.