CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2008
    Posts
    4

    I learned VB 6, now im having issues with .net

    I took VB 2 years ago in school, and of course the year after i take it they upgrade to .net.. Anyways, I was wondering why this code works vs the other.


    loginText.Left = 12
    loginText.Top = 47
    loginText.Width = 33
    loginText.Height = 13

    that works, and that's how i learned to do it. But i was messing around in the .net one and i was wondering why something like this wouldnt work

    loginText.Location.X = 12
    loginText.Location.Y = 47
    loginText.Size.Width = 33
    loginText.Size.Height = 13

  2. #2
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: I learned VB 6, now im having issues with .net

    1) You had a problem with school then two years ago. VB6 was officially declared dead in 2004. It should not have been taught in ANY school after 2003 [5 years ago]

    2) Value Types (Like Point) can not be modified in that way. When you call
    Code:
    Item.Location.X = 10
    The first part (Item.Location) returns a COPY of the Point instance, which is what you would be attempting to modify. It would NOT effect the original instance inside of Item.

    There is a world of difference between VB.NET and previous versions. You must "unlearn" the majority of what you previously learned.

    Consider the difference in spoken (slang) language between Los Angles, CA and London, Eng. The two are both English, but one does NOT translate to the other...
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  3. #3
    Join Date
    Oct 2008
    Posts
    4

    Re: I learned VB 6, now im having issues with .net

    Alright, could you explain what this means?

    Warning 1 Variable 'loginText' is used before it has been assigned a value. A null reference exception could result at runtime.

    What im trying to do is create object, when the user clicks certain things. This is an example.

    Dim loginText As Label
    loginText.Left = 12
    loginText.Top = 47
    loginText.Width = 33
    loginText.Height = 13
    loginText.Text = "Login"

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: I learned VB 6, now im having issues with .net

    It's warning you that you didn't initialize it. There you go!

    Code:
    Dim loginText As Label = new label
    loginText.Left = 12
    loginText.Top = 47
    loginText.Width = 33
    loginText.Height = 13
    loginText.Text = "Login"
    Still have to show it, and make it visible.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Oct 2008
    Posts
    4

    Re: I learned VB 6, now im having issues with .net

    Thanks, that helped me quite a bit, specially in stuff i hadn't coded yet. But I'm in another situation. This is the menu strip button property.

    Private Sub LoginToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoginToolStripMenuItem.Click

    I also added loginText.visible = true
    but it doesnt show up when i click.

  6. #6
    Join Date
    Jan 2006
    Location
    Pearl of the orient
    Posts
    304

    Re: I learned VB 6, now im having issues with .net

    Quote Originally Posted by TheCPUWizard View Post
    1) You had a problem with school then two years ago. VB6 was officially declared dead in 2004. It should not have been taught in ANY school after 2003 [5 years ago]
    There are still opportunities left for VB6.0 knowledge like for maintaining applications made with it and as a hobby, you can still do so much with it...

  7. #7
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: I learned VB 6, now im having issues with .net

    Quote Originally Posted by dee-u View Post
    There are still opportunities left for VB6.0 knowledge like for maintaining applications made with it and as a hobby, you can still do so much with it...
    However as rule of thumb..

    * DO NOT start a new project in VB6, Rather Use .NET..

    * IF the VB6 requires major work, Do a complete rewrite in .NET ..

    * In .NET, it is easier to get most funtionality out of Vista & XP with minimum Code. VB6 requires tons of API's..

    * MS is dropping VB6 backwards compatibility in the OS, (cant remember the article) , Soon the VB6 Proggy will need a .NET upgrade.
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

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

Featured