Taking Values from another form to Table layout panel ("How?")

Beginner

Well-known member
Joined
Mar 12, 2008
Messages
114
Programming Experience
Beginner
Ok guys heres what i want to do.

When i hit the Calculate Button on form1.

I want To do this ....
[GIF ANIMATED IMAGE]

12fl8.gif


Diametral Pitch is located under Form1

While where i want the value to show is Common_Features

So what approach do i use do i create a text box ? Or a label ? I want no user input just the number in a nice way
 
I'll Re-Phrase what i said.

My aim is to get this value.

2005193521074775269_rs.jpg


What is the best approch to do so ? Do i create a text box ? and place it in the (1,1) (Row, Column). ive used a paint program to insert the number 0.25 just to explain what i want


When do i want this number to appear ?

When the calculate button is hit.

2005162900054054381_rs.jpg


So i guess the code should go there.

Methodology ? I dont want the number to appear just like that. Since ive built a user interface that number specifically depends on the value entered in NUD controller that ive changed its name to pd.
This value entered here.
2000960933809274588_rs.jpg


now what i want to happen back in the form that ive changed its name to Common_Features , i mean this form

2005193521074775269_rs.jpg


A mathematical operation to take place. The concept or the rule i want to use is 1/(whatever value is entered in the pd NUD)

So how do i implement the call function ? Call whatever value is entered in the NUD bring it up to current form then 1/value.
 
Last edited:
LOL interesting post.
I have to pass the data twice. The first form passes the user input to the second form, which stores it in member variables. It can then pass that data on to the third form.

jmcilhinney said:
There are really two choices:

1. Declare one or more properties in the target form for the data that needs to be passed in. You then create the form object and then set the appropriate properties. Setting properties you've declared yourself is exactly like setting existing properties, e.g. Text. To declare a property just type the word "property" and hit Enter. The IDE will create the skeleton which you can then flesh out as needed.

2. Declare a constructor in the target form and add a parameter for each value you want to pass in. A constructor is just a method named "New". You then pass the data in when you create the object, rather than afterwards. To create a constructor you can select "New" from the drop-down box at the top, right of the code window, then add the parameters yourself.


I still did not know how to implement.

I want to take the value from the NUD controller next to diametral pitch pd.

Then put it in the following equation 1/(value taken from NUD) to get 0.25 instead of label 1

2002991927736552529_rs.jpg
 
Why don't you pass the value in to the Calculator form when you create it, then on the form load event you can do the calculations and display the value you want?
 
Thats what i want to do. But i dont know what is the code to pass the value and what is the code to call back the value. Any help would be great ;-)
 
This is why you have been told numerous times to pick up a book on programming in VB.Net 2005. We are ending up having to write most of your project for you that you should be learning from reading the book.

You create a New sub in the second form and enter a parameter for it. Probably something like
VB.NET:
public sub New(dp as double)

end sub

Assign the variable to a global variable in your second form's class and use it in your calculation.
 
May you provide me with a book name that matches my case. The reason i have no time to read is that im out of time. Im a mechanical Engineer i aint no coder or programmer. Im doing this VB thing for one reason. I mentioned in Graduation project 1 the word ( My program does this & this ....... ) So the examining comunitee aid how come you say you have a program and all we can see is an excel sheet. Its just a couple of weeks before my final presentation starts. Thanks to all members of this forum i got so much help.


Back to subject: How do i assing a global variable ?
A global variable is a variable that is valid in all forms ?
 
May you provide me with a book name that matches my case.

Programming Microsoft Visual Basic 2005: The Language

It would take maybe a couple hours for you to read the first 1/2 or so of the book that would be relevant to you and you would actually have an inkling as to how to actually program.
 
I am sending the value into one form then showing a different form.
Purpose is that the different form consists of 3 tables so i set them into buttons. each button will open a table.I can read many options in my mind. Do everything in the Calculation Button ?(form1) or Send values to second form then from second to third to mylabel ?

If you were in my place what approach will you use ?


I dont have to buy the book i managed to download the book in CHM format :D
So what chapter shall i start with :D

bookfp2.jpg
 
Last edited:
Just read through it. I don't imagine that chapters 1 would have too much value, or chapters 16-22. Since I doubt you will be doing any inheritance you could skip chapter 8 and probably chapter 10 as well. I will respond to your other question in a little bit, it's been a long day of work so I am going to go home and grab a bite to eat before I delve into that.
 
I'll do my best. Although i prefer working problems by asking here. Thanks for the heads up mate :D. C-ya Around.

Edit:Frankly Speaking Even if i read this book till tommorow. I wont find a solution to this thread. Since you advised me to read the book and ignore like 10 chapters. The rest is just useless. Thats why i hate reading VB books. The only way to learn is by asking and making mistakes. Even if it takes time but at least I'll learn something from my mistakes. Another thing that book is regarding .Net 2005 im using .Net 2008. I hope somone sends me a URL that perfectly matches my case or help me code this part of the project.
 
Last edited:
Ok heres what ive done. In form1 i had this code

Public Class Form1
VB.NET:
 Public Shared Diametral_Pitch As String

and in the NUD controller i had this code

VB.NET:
    Private Sub dp_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dp.ValueChanged
        Diametral_Pitch = dp.Text
    End Sub

I was testing to see if im getting the correct value.
In the Second form i had a label.
and the following code

VB.NET:
    Private Sub second_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Label1.Text = Form1.Diametral_Pitch
    End Sub
End Class

The problem was that the value was less than the NUD value by 1. And after i hit the back button and change the value of the NUD and hit the calculate button. The previous values remains so in my case the number 6 remains forever untill i terminate the program and run again.

19173162yh3.jpg


97406613oc2.jpg
 
Now i tried putting the code in the calculation Button


VB.NET:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Diametral_Pitch = dp.Text
        second.Show()
        Me.Hide()

    End Sub


When i hit the calculate button i get the same exact number as in the NUD.
I hit the "back" button change the value of the NUD and hit the "Calculate" Button and no changes take effect. So now it works only for one time. i want to change infinite number of times.
 
Back
Top