Results 1 to 10 of 10

Thread: Total Newb to VB .Net

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2004
    Posts
    22

    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:
    1. Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
    2.         Dim form1 As Form1
    3.         form1.TextBox1.Text = Me.TextBox1.Text
    4.     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

  2. #2
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949

    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:
    1. Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
    2.         Dim form1 As Form1
    3.         form1.TextBox1.Text = Me.TextBox1.Text
    4.     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.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2004
    Posts
    22
    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...

  4. #4
    Lively Member ayan's Avatar
    Join Date
    Jan 2004
    Posts
    112
    just set the textbox1 on form1 as public shared and on textbox1_textchange of form2, put this
    VB Code:
    1. form1.textbox1.text=me.textbox1.text
    also put this on form1_load
    VB Code:
    1. dim f as new form2
    2. f.show
    hope this helps...

  5. #5
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    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.

  6. #6
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    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:
    1. Dim frm1 AS New Form1
    2.  
    3. Public Sub Main()
    4.   Application.Run(frm1)
    5. End Sub

    Make Sub Main your startup object


    In the Load Event of Form1 put

    VB Code:
    1. Dim frm2 AS New Form2  (This is called Creating an instance of
    2.                                                         Form2)
    3.     frm2.Show.Dialog
    4.     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.

  7. #7
    Lively Member ayan's Avatar
    Join Date
    Jan 2004
    Posts
    112
    you mean my code doesn't work?

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Jun 2004
    Posts
    22
    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?

  9. #9
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    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.

  10. #10
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    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:
    1. 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
  •  



Click Here to Expand Forum to Full Width