|
-
Jun 13th, 2004, 05:30 PM
#1
Thread Starter
Junior Member
Total Newb to VB .Net
Ok i have just recently upgraded from vb6 to vb .net 2003. And I had no idea the coding was going to be this much different. So the problem i ran into is this:
Lets Say i have two forms (Form1 and Form2) Each with a textbox(TextBox1) on each. When i change Form2.textbox1.text i want form1.textbox1.text to change to form2.texbox1.text.
Example Code i Have In form 2:
VB Code:
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim form1 As Form1
form1.TextBox1.Text = Me.TextBox1.Text
End Sub
But when i run this it generates an error.. What do i do? Im a newb at VB .Net and it all seems so different to me than vb6.
Thanks,
Cooldude4u2no
-
Jun 13th, 2004, 06:04 PM
#2
PowerPoster
Re: Total Newb to VB .Net
Originally posted by cooldude4u2no
Ok i have just recently upgraded from vb6 to vb .net 2003. And I had no idea the coding was going to be this much different. So the problem i ran into is this:
Lets Say i have two forms (Form1 and Form2) Each with a textbox(TextBox1) on each. When i change Form2.textbox1.text i want form1.textbox1.text to change to form2.texbox1.text.
Example Code i Have In form 2:
VB Code:
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim form1 As Form1
form1.TextBox1.Text = Me.TextBox1.Text
End Sub
But when i run this it generates an error.. What do i do? Im a newb at VB .Net and it all seems so different to me than vb6.
Thanks,
Cooldude4u2no
If you search this forum you will find many threads on this. There are several ways to do it and it depends on what you want to achieve.
Which form do you want to use to start the project?
Do you want to close either or both forms while the project is running?
If you altered your above code line to
Dim form1 as New Form1 (but preferably Dim frm1 as New form1)
then it would work, but how did you create an instance of form2???
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Jun 13th, 2004, 06:19 PM
#3
Thread Starter
Junior Member
umm i dont know how to create a instance of it i dont guess... i just opened up a new form and named it form 2 lol...like i did in VB6... This stuff is way different i guess..:/
Oh and Form1 is the startup form...but in the form1_load event it loads form2 also...
-
Jun 13th, 2004, 08:18 PM
#4
Lively Member
just set the textbox1 on form1 as public shared and on textbox1_textchange of form2, put this
VB Code:
form1.textbox1.text=me.textbox1.text
also put this on form1_load
VB Code:
dim f as new form2
f.show
hope this helps...
-
Jun 14th, 2004, 06:34 AM
#5
PowerPoster
Originally posted by ayan
just set the textbox1 on form1 as public shared and on textbox1_textchange of form2, put this
[
Just HOW would he do that??? (There is a way but it is definitely not recommended as it will give rise to other problems, but I would like to see your suggestion)
(If you are going to say set the Modifiers property, have a look at the options available).
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Jun 14th, 2004, 06:56 AM
#6
PowerPoster
Originally posted by cooldude4u2no
umm i dont know how to create a instance of it i dont guess... i just opened up a new form and named it form 2 lol...like i did in VB6... This stuff is way different i guess..:/
Oh and Form1 is the startup form...but in the form1_load event it loads form2 also...
Hi,
Yes, VB.NET has an entirely different approach from VB6. Although there are apparent similarities in the words used, you have to forget virtually all of your VB6 knowledge. You cannot simply just move into .Net from 6 without learing the .Net fundamentals.
You must get a beginners book and I suggest ISBN 0-672-32537-3 which is Sams Teach Yourself Microsoft Visual Basic.Net 2003 in 24 Hours, by James Foxall. You can easily go through it in two weeks if you spend about 2 hours a day on it.
Just to get you started the right way, Use a module and in it put
VB Code:
Dim frm1 AS New Form1
Public Sub Main()
Application.Run(frm1)
End Sub
Make Sub Main your startup object
In the Load Event of Form1 put
VB Code:
Dim frm2 AS New Form2 (This is called Creating an instance of
Form2)
frm2.Show.Dialog
frm1.TextBox1.Text = Me.TextBox1.Text
But this is just the first step in a long, but rewarding journey.
By the way, you will not be able to see frm1 unless you position form2 differently from it, or close frm2.
As an aid, name forms you design as fcls1 rather than Form1 and then instance them as frm1.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Jun 14th, 2004, 07:45 PM
#7
Lively Member
you mean my code doesn't work?
-
Jun 14th, 2004, 10:57 PM
#8
Thread Starter
Junior Member
Thanks Guys..Ur suggestions got me up and rolling... I got another problem.. im using the treeview control...How do you remove a treeview node by its KEY and not its INDEX? Ive tried every possible solution i could think of... Oh and taxes yeah i order me a book on .Net but i jsut ordered it day b4 yesterday... i hope it gets here in the next week or so.. i need it very badly.. so do you know about the treeview question i brought up?
-
Jun 15th, 2004, 05:22 AM
#9
PowerPoster
Originally posted by ayan
you mean my code doesn't work?
Look again at my post. I did not quote your code, nor did I refer to it..
What I meant was what I said. Just how do YOU suggest setting a textbox to Public Shared? There is no such option in the Modifiers property.
If you are going to suggest altering the property of the TextBox in the form code view from the keyboard then that is specifically banned. If you do that, it will allow your posted code to work but you will get problems in future when you use that textbox.
Of course, it is possible you know another way and that is what I am waiting for with bated breath.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Jun 15th, 2004, 05:39 AM
#10
PowerPoster
Originally posted by cooldude4u2no
Thanks Guys..Ur suggestions got me up and rolling... I got another problem.. im using the treeview control...How do you remove a treeview node by its KEY and not its INDEX?
Guess I don't quite follow you here. Normally the node to be deleted would be selected by the user, who would then press a button to remove that node, in which case the use of Key or Index does not enter into it.
VB Code:
TreeView1.Nodes.Remove(TreeView1.SelectedNode)
Have I misunderstood you?
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|