hi, Can anyone tell me how to retrieve data from one form to another in VB.net,,,????
Actually I have a form in which i have 5 values with labels and text boxes,I know I can edit n save them,, i have linked this through Data base but i want that if i have one other form on which i need all these values as these were on the 1st form,,, is it possible??? if i edit all on 1st form, it will automatically change in the next one?????

Recommended Answers

All 14 Replies

every things is possible.
you means when you change value in 1st form it will change value in 2nd form?

yes i mean when i change value in first form in the box,,, it would change automatically in the text box of the second,,eg. i have length=10 m in the first form,,in the text box,,, and i hav other form with same length,,, if i will change the length to 12 m in the first form,, then it would auto change in second form,,, plz tell me completely in nice n easy way so that i can take help from that

make shared variable to able you connected with controls.
in first form :
declare this code on top of all event.

public shared temp as string

in any event in form 1 :
temp = textbox1.text

In other Form :
in any event on other form :

textbox2 = Form1.temp

Hi,, Thx for your reply ,,, I will try this to solve by coding you have given to me,,,
If you have some time,,, Plz solve my one more problem so that i can easily achieve my target,,,,

Can u tell me how to use formula in VB,, I mean that,
If I have a formula e.g. Stress=Force/Area,,, I want to use the value of Force and Area from the first form,,, like I have Force=10N and Area=10cm., I want to calculate the value of stress in the other form ,,, how can I use this formula by automatically taking the values of force and area from the first form by just only clicking on the stress to get a value,,, and
If I change the values of force and Area,, the value will change for stress by just clicking on Stress,,,,

SEND ME THE CODING OF THAT ALL PROCESS,, SO THAT ITS EASY FOR ME TO UNDERSTAND, BECOZ I HAVE STARTED VB FEW DAYS BACK.
Plz plz plz plz plz help me in this case,, I have a problem,,

Again Thx for helping me for my previous question.

If I have a formula e.g. Stress=Force/Area,,, I want to use the value of Force and Area from the first form,,, like I have Force=10N and Area=10cm., I want to calculate the value of stress in the other form ,,, how can I use this formula by automatically taking the values of force and area from the first form by just only clicking on the stress to get a value,,, and
If I change the values of force and Area,, the value will change for stress by just clicking on Stress

you said 'clicking on Stress'. i confused what the Stress is?
a result for Force / Area? or a button to get value of this dividing? or button to open other form and the result of calculated will appear on other form?

you said 'clicking on Stress'. i confused what the Stress is?
a result for Force / Area?
yes result of force/area
or a button to get value of this dividing?
yes a button to divide

hi,,I mean that if stress is button on the form on which i hav force=10N and area=10cm,,, as i know that formula to calculate stress is stress=force/area,,,,, if i click a button name as stress , it would calculate the result for the formula of stress in the text box on the same form and if i will change the value of force and area later, then formula must work for that values(new values),,,, i hope u understand now my question??????
PLEASE MAKE SURE TO TELL ME STEPS THAT WHAT U R DOING WITH CODINGS,,

i know when force and formula changing the result will changing.
see this :
On first form :
- input force n area
- calculated formula when button stress clicking
- Display Result???

On Second or Other form :
- Display Result???

where the value will display? on First form or other form?

where the value will display? on First form or other form?

THE VALUE MUST DISPLAY ON THE FIRST FORM, LIKE I WANT TO DISPLAY THE VALUE OF FORMULA IN A TEXT BOX ON THE SAME FORM NEAR THE BUTTON OF STRESS,,,

you just want to divide 2 value and you can't do that!!! oh...please do something before posting..show your effort friend..
Read this => We only give homework help to those who show effort
i write pseudo code, you convert into vb.net code :
On Button event

Begin
force -> Integer;
area -> Integer;
result -> Real;

force <- input from textbox force.
area <-  input from textbox area.
result = force / area;

display result in label or textbox
End

try it and post your vb code!

I will post you VB codes asap,,, BUt i was busy with how to link excel file with VB,, I am new in this field.plz check the codes and tell me the error

I am doing the coding like this,, but only excel file is opening not the complete spreadsheet on which i have done work is opening,,it shows path error while running, check n answer to my question
coding is below:


Imports Microsoft.Office.Interop
Imports System.IO


Public Class Form1


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim xlsApp As Excel.Application
Dim xlsWB As Excel.Workbook
Dim xlsSheet As Excel.Worksheet
Dim xlsCell As Excel.Range

xlsApp = New Excel.Application
xlsApp.Visible = True
xlsWB = xlsApp.Workbooks.Open("C:\Desktop\Book3.xlsx")
xlsSheet = xlsWB.Worksheets(1)
xlsCell = xlsSheet.Range("A1")
MsgBox(xlsCell.Value)

End Sub

End Class

I will post you VB codes asap,,, BUt i was busy with how to link excel file with VB,, I am new in this field.plz check the codes and tell me the error

I am doing the coding like this,, but only excel file is opening not the complete spreadsheet on which i have done work is opening,,it shows path error while running, check n answer to my question
coding is below:


Imports Microsoft.Office.Interop
Imports System.IO


Public Class Form1


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim xlsApp As Excel.Application
Dim xlsWB As Excel.Workbook
Dim xlsSheet As Excel.Worksheet
Dim xlsCell As Excel.Range

xlsApp = New Excel.Application
xlsApp.Visible = True
xlsWB = xlsApp.Workbooks.Open("C:\Desktop\Book3.xlsx")
xlsSheet = xlsWB.Worksheets(1)
xlsCell = xlsSheet.Range("A1")
MsgBox(xlsCell.Value)

End Sub

End Class

your code is fine. it was opened excel file and showing value of A1 on message box.

hi,, can anyone tell me how to use constraints in VB.net,,, like i mean to say if i have value 10 to 20cm,, or it can b some other also,, n i wana put some constraint to that if the user wana put value above or below this value , it will not work,,,is it possible, tell me coding

I can only know in this that how to constant a text like i can put a password and username,, if it match with that which i hav set before it will work, other wise msg comes TRY AGAIN.I know only this

but i wana know how to use greater than or less than option in this. hope u understand ma question???

hello sir this is charitha
i have the same requirement but i have some problem i will clearly explain
i have 4 client computers connected to server
when on one client computer if i change this button color it should reflect the same in all the clients computers i am storing that button status in database
please let me know how to accomplish this task

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.