CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2004
    Posts
    218

    help with initial

    the code like
    Code:
    Private Sub Form_Load()
    Dim num As Integer
    num = 3
    End Sub
    when I use watch to view the value of num, it show the value is 0, why?

  2. #2
    Join Date
    Aug 2002
    Location
    Kerala
    Posts
    1,183

    Re: help with initial

    after num = 3 it will contain 3

  3. #3
    Join Date
    Feb 2004
    Posts
    218

    Re: help with initial

    Normally it is, but when I use quick watch to view, it show the value is 0. this is why I wondering

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

    Re: help with initial

    Code:
    Private Sub Form_Load()
    Dim num As Integer
    num = 3
    End Sub
    basicaly you've defined num and a local variable to be used only with in the sub Form_Load. Any reference to it from any other sub will return null..

    To use num is a number of subs rather use
    Code:
    private num As Integer
     
    Private Sub Form_Load()
    num = 3
    End Sub
    hope this helps..

    Gremmy..
    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.

  5. #5
    Join Date
    Feb 2004
    Posts
    218

    Re: help with initial

    I find the fault now, it is my fault, i put the codes which relationed to num wrongly in one function. Thank you.

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