473,465 Members | 1,915 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

[2005] multiple form help!!!

12 New Member
Hi

I must be missing something very straightforward.

I load data in Form1 and show 'Name', 'Abreviation', 'Value1', 'Value2' etc

In Form 2 i have to show by a Combo Box into a list box the 'Name' and calculation of 'Value1 and 'Value2.

However when i go into Form 2 i just get the info that i asked to look at on Form 1.
I must be brain dead or something.

Help Please
Mar 27 '07 #1
8 2063
SammyB
807 Recognized Expert Contributor
Hi

I must be missing something very straightforward.

I load data in Form1 and show 'Name', 'Abreviation', 'Value1', 'Value2' etc

In Form 2 i have to show by a Combo Box into a list box the 'Name' and calculation of 'Value1 and 'Value2.

However when i go into Form 2 i just get the info that i asked to look at on Form 1.
I must be brain dead or something.

Help Please
No, you're not brain dead: it's hard the first time and difficult the second time. :) You just need to do two things:
  1. Pass a Form1 reference to Form2 by overloading Form2's constructor.
  2. In the Forms Designer for Form1, set the Modifiers to Protected or Public.
Mar 27 '07 #2
jenkins0706
12 New Member
Hi
[quote]
No, you're not brain dead: it's hard the first time and difficult the second time. You just need to do two things:
Pass a Form1 reference to Form2 by overloading Form2's constructor.
In the Forms Designer for Form1, set the Modifiers to Protected or Public
[quote]

I have gone into Forms Designer for Form1 and their is no Modifier to set.
And what do you mean by overloading Form2's constructor.

Also will this still enable me in Form 2 for each 'Name' Selected from ComboBox i will be able to show each one in a List Box

Thanks
Mar 27 '07 #3
jenkins0706
12 New Member
:wave:
:wave:

:afrog:

I'm all goggle eyed

Trying to sort problem my self but just getting lost

HELP PLEASE

Thanks
Mar 27 '07 #4
SammyB
807 Recognized Expert Contributor
:wave:
:wave:

:afrog:

I'm all goggle eyed

Trying to sort problem my self but just getting lost

HELP PLEASE

Thanks
Sorry, I missed your eariler post, my spam filter removes post notifications. Your thread question title has 2005 in it and I assumed that you are using VB.NET 2005. But from your replies, it seems that you are not. What VB are you using? VBA, VB6, or VB.NET
Mar 27 '07 #5
jenkins0706
12 New Member
Hi

Am using 'Visual Studio 2005' v.8 with the MS .Net Framework v.2

Hope this helps

Thanks
Mar 27 '07 #6
SammyB
807 Recognized Expert Contributor
Hi

Am using 'Visual Studio 2005' v.8 with the MS .Net Framework v.2

Hope this helps

Thanks
OK. let's start again and just create a simple two form example in VB. Then, you can use the principles for your forms.
  1. Open VB.NET, create a new Win App and add another form
  2. Put a textbox and a button on form1
  3. Select the textbox and in the properties window change the Modifiers property from Friend to Public
  4. Open the form designer for form2 and double-click on the form to create a load event
  5. Add a property to Form2 that will hold the Form1 object. Now form2 code should look like:
Expand|Select|Wrap|Line Numbers
  1. Public Class Form2
  2.     Public FrmParent As Form1
  3.  
  4.     Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  5.         MsgBox(FrmParent.TextBox1.Text)
  6.     End Sub
  7. End Class
Finally, switch back to form1 and double click on the button. Add the following code so that form2 code looks like

Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  3.         Dim frm As New Form2
  4.         frm.FrmParent = Me
  5.         frm.Show()
  6.     End Sub
  7. End Class
Running this, you can see how multiple forms can work together. In form1, the form1 object is called "me", and the form2 object is called frm, In form2, the form1 object is called FrmParent and the form2 object is called "me". Either form can access anthing in the other form that has been declared public: controls, properties, or even methods (Sub). So, now you need to decide how to communicate and how events on one form should affect the other form. --Sam
Mar 27 '07 #7
jenkins0706
12 New Member
Hi
This is part of the code in Form2 that requires the info from Form1

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmbSpecies_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbSpecies.SelectedIndexChanged
  2.         Dim Perc As Decimal
  3.  
  4.         'cmbSpecies.Items.Add(Form1.txbSpecies.Text)
  5.         Select Case CStr(cmbSpecies.SelectedItem)
  6.             Case "Brown argus"
  7.                 If CDbl(Form1.txb2000.Text) <= 0 Then
  8.                     MsgBox("This is New Data for " & Form1.txbSpecies.Text)
  9.                 End If
  10.                 Perc = CDec(CInt(CStr(CDbl(Form1.txb2005.Text) - CDbl(Form1.txb2000.Text))) / (CInt(CStr(CDbl(Form1.txb2000.Text))))) * 100
  11.             Case "Glanville fritillary"
  12.                 If CDbl(Form1.txb2000.Text) <= 0 Then
  13.                     MsgBox("This is New Data for " & Form1.txbSpecies.Text)
  14.                 End If
  15.                 Perc = CDec(CInt(CStr(CDbl(Form1.txb2005.Text) - CDbl(Form1.txb2000.Text))) / (CInt(CStr(CDbl(Form1.txb2000.Text))))) * 100
  16.             Case "Purple hairstreak"
  17.                 If CDbl(Form1.txb2000.Text) <= 0 Then
  18.                     MsgBox("This is New Data for " & Form1.txbSpecies.Text)
  19.                 End If
  20.                 Perc = CDec(CInt(CStr(CDbl(Form1.txb2005.Text) - CDbl(Form1.txb2000.Text))) / (CInt(CStr(CDbl(Form1.txb2000.Text))))) * 100
  21.             Case "Silver studded blue"
  22.                 If CDbl(Form1.txb2000.Text) <= 0 Then
  23.                     MsgBox("This is New Data for " & Form1.txbSpecies.Text)
  24.                 End If
  25.                 Perc = CDec(CInt(CStr(CDbl(Form1.txb2005.Text) - CDbl(Form1.txb2000.Text))) / (CInt(CStr(CDbl(Form1.txb2000.Text))))) * 100
  26.             Case "Chalkhill blue"
  27.                 If CDbl(Form1.txb2000.Text) <= 0 Then
  28.                     MsgBox("This is New Data for " & Form1.txbSpecies.Text)
  29.                 End If
  30.                 Perc = CDec(CInt(CStr(CDbl(Form1.txb2005.Text) - CDbl(Form1.txb2000.Text))) / (CInt(CStr(CDbl(Form1.txb2000.Text))))) * 100
  31.             Case "Large blue"
  32.                 If CDbl(Form1.txb2000.Text) <= 0 Then
  33.                     MsgBox("This is New Data for " & Form1.txbSpecies.Text)
  34.                 End If
  35.                 Perc = CDec(CInt(CStr(CDbl(Form1.txb2005.Text) - CDbl(Form1.txb2000.Text))) / (CInt(CStr(CDbl(Form1.txb2000.Text))))) * 100
  36.             Case "Common blue"
  37.                 If CDbl(Form1.txb2000.Text) <= 0 Then
  38.                     MsgBox("This is New Data for " & Form1.txbSpecies.Text)
  39.                 End If
  40.                 Perc = CDec(CInt(CStr(CDbl(Form1.txb2005.Text) - CDbl(Form1.txb2000.Text))) / (CInt(CStr(CDbl(Form1.txb2000.Text))))) * 100
  41.             Case "Grizzled skipper"
  42.                 If CDbl(Form1.txb2000.Text) <= 0 Then
  43.                     MsgBox("This is New Data for " & Form1.txbSpecies.Text)
  44.                 End If
  45.                 Perc = CDec(CInt(CStr(CDbl(Form1.txb2005.Text) - CDbl(Form1.txb2000.Text))) / (CInt(CStr(CDbl(Form1.txb2000.Text))))) * 100
  46.             Case "Silver washed fritillary"
  47.                 If CDbl(Form1.txb2000.Text) <= 0 Then
  48.                     MsgBox("This is New Data for " & Form1.txbSpecies.Text)
  49.                 End If
  50.                 Perc = CDec(CInt(CStr(CDbl(Form1.txb2005.Text) - CDbl(Form1.txb2000.Text))) / (CInt(CStr(CDbl(Form1.txb2000.Text))))) * 100
  51.  
  52.         End Select
  53.  
  54.         'Cannot seem to make this Format work 
  55.         Format(Perc, "0.00%")
  56.         'This does not seem to be working. Trying to make sure that
  57.         'a Species is selected
  58.         If cmbSpecies.SelectedIndex <> -1 Then
  59.  
  60.             lbxButter.Items.Add((cmbSpecies.Text) & "                   " & CDbl((CInt(FormatCurrency(Perc)))))
  61.         End If
  62.  
  63.     End Sub

This is part of the code in Form1
Expand|Select|Wrap|Line Numbers
  1. Private Sub btnForm2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnForm2.Click
  2.  
  3.  
  4.  
  5.         Dim frmForm2 As New Form2
  6.  
  7.         frmForm2.Show()
  8.  
  9.  
  10.     End Sub
  11.  
I have now made the Text boxes in Form1 Public (in Modifier) and the btnForm in Form 1 also Public.

ann.jenkins1606@btinternet.com
I still have the problem that when i select from the Combo box in Form2 i only obtain info that is showing on Form1, i could have both forms open and display from Form1 and select on Form2.
I hope i have not sent too much info.

My brain is almost dead, but i am determined

Thanks
Mar 27 '07 #8
jenkins0706
12 New Member
Hi

Sorry to be a nusiance any help out there

Thanks
Mar 28 '07 #9

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

Similar topics

2
by: perplexed | last post by:
Is there a way to combine the values of multiple form items such as two textboxes and one radio button for insertion into one MYSQL database field?
7
by: Matt | last post by:
I have an interactive web page that I need to prevent refreshes on. The problem is that I want to ALLOW resubmissions, but only via the submit button. My web page has two forms on it, one form for...
2
by: Roshawn Dawson | last post by:
Hi All, When you open a .aspx page in VS.NET, it has the form tags (<form>....</form>) already present. I am trying to create a web user control that contains textboxes, buttons, and other form...
0
by: Johnny E. Liner | last post by:
Hello, I am working on a WebApp and I am running into some trouble with multiple form tags. I have a Master page that contains three controls: MasterTop, MasterBottom, and Content. The...
0
by: faww | last post by:
i have been working with visual basic.net for about a year, ive actually managed to pass my teacher's knowledge of it, and he cant help me anymore with it. ive been designing a role playing game, and...
1
by: rmsterling | last post by:
All, Subject : SQL Server 2005 SSIS Script Help - XML Secure Pull in to DB table I was wondering if any of you could help me with something..... I want to design a SSIS script that will pull...
1
Fary4u
by: Fary4u | last post by:
Hi Guys i'm trying to upload a file, i've tried 3 different methods but still not work out i don't know how to over come this problem hidden file value, multiple form or popup uploading. 1-...
0
by: Mary arilene | last post by:
Hi, I currenlt building a form and would like some help validating multiple checkboxes and receiving values. I'm using two two pages there asp pages. HTML code(with the body tag) ...
1
by: hidhayathullah | last post by:
I use request.Form(fieldname) it is work single form i used multiple form then not work this coding-request.Form(fieldname) please help me
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.