Results 1 to 18 of 18

Thread: .NET Newbe needs help

  1. #1

    Thread Starter
    Frenzied Member RudyL's Avatar
    Join Date
    Mar 2001
    Location
    Chicago
    Posts
    1,519

    Question .NET Newbe needs help

    Ok.. I am completely new to .NET (but have been doing VBx for years now) so I have what might be a very basic question..

    I have created a "Splash Form" that resembles the splash form in VB6. My question is how and where would I put code to populate the labels? I want to do it in the form load event but I do not see one. Is there even an array like in vb6 such as App.Version type of thing?

    Thanks,
    Rudy
    10 different ways to skin a cat and amazingly enough each and every one has the same result, the cat gets skinned! The same can be applied to code, so be nice and accept each others "preferences".

  2. #2
    Fanatic Member LITHIA's Avatar
    Join Date
    Dec 2002
    Location
    UK, England
    Posts
    575
    Why do you want to populate the labels at run time? Just change them at design time in the form designer...

    and I'm not sure what you're on about with App.Version thing... and there is a load on each form. Don't know why you can't see it

  3. #3
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    You can get the version like this:
    VB Code:
    1. MessageBox.Show(Application.ProductVersion)

  4. #4

    Thread Starter
    Frenzied Member RudyL's Avatar
    Join Date
    Mar 2001
    Location
    Chicago
    Posts
    1,519
    In Vb I could make a lable reflect the build version of the code by saying:

    VB Code:
    1. label.caption = App.Version

    By doing this I do not have to remember to change the lable every time I build the program..

    Make sense?
    10 different ways to skin a cat and amazingly enough each and every one has the same result, the cat gets skinned! The same can be applied to code, so be nice and accept each others "preferences".

  5. #5
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Oh, and if you can't see the Form_Load event, you can get to it in a couple different ways. One, just double click on your form and the IDE will create the method for you and bring you there. Or, if you're already in the code, the drop down box on top and to the left, click that and choose (Form1 Events) - or whatever your form name is, then on the right drop down, choose the Load method.

  6. #6

    Thread Starter
    Frenzied Member RudyL's Avatar
    Join Date
    Mar 2001
    Location
    Chicago
    Posts
    1,519
    Originally posted by Mike Hildner
    You can get the version like this:
    VB Code:
    1. MessageBox.Show(Application.ProductVersion)
    I think that is exactly what I was looking for.

    Two quextions though..

    1. How would code in VB6

    VB Code:
    1. form1.lblcaption.caption = App.Major & "." & App.Minor & "." & App.Revision

    Translate to .NET?
    I got part of it:
    VB Code:
    1. {Needs the form name here I think} lblVersion.Text = Application.ProductVersion

    The other question is that the version displays as 1.0.1671.23823 - However I have not built it that many time.. I don't think so anyways..
    10 different ways to skin a cat and amazingly enough each and every one has the same result, the cat gets skinned! The same can be applied to code, so be nice and accept each others "preferences".

  7. #7
    Fanatic Member LITHIA's Avatar
    Join Date
    Dec 2002
    Location
    UK, England
    Posts
    575
    sorry, i didn't realise u wanted that

    i thought u meant static text, i was wondering why you would want to do it at run time...

  8. #8

    Thread Starter
    Frenzied Member RudyL's Avatar
    Join Date
    Mar 2001
    Location
    Chicago
    Posts
    1,519
    Originally posted by Mike Hildner
    Oh, and if you can't see the Form_Load event, you can get to it in a couple different ways. One, just double click on your form and the IDE will create the method for you and bring you there. Or, if you're already in the code, the drop down box on top and to the left, click that and choose (Form1 Events) - or whatever your form name is, then on the right drop down, choose the Load method.
    Thanks for that, I finally found it. I was in the code for a fram (Group Box).. ooops...
    10 different ways to skin a cat and amazingly enough each and every one has the same result, the cat gets skinned! The same can be applied to code, so be nice and accept each others "preferences".

  9. #9
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    VB Code:
    1. form1.lblcaption.caption = App.Major & "." & App.Minor & "." & App.Revision
    Would be something like
    VB Code:
    1. Label1.Text = Application.ProductVersion

    I have no idea why the build numbers look like that, never really looked into it. Something to research. FYI check out your AssemblyInfo.vb file if you want to mess with the version. Here's the relevant part:
    VB Code:
    1. ' Version information for an assembly consists of the following four values:
    2. '
    3. '      Major Version
    4. '      Minor Version
    5. '      Build Number
    6. '      Revision
    7. '
    8. ' You can specify all the values or you can default the Build and Revision Numbers
    9. ' by using the '*' as shown below:
    10.  
    11. <Assembly: AssemblyVersion("1.0.*")>

    I usually just change mine to 1.2, 1.3 or 2.0 or whatever.

  10. #10

    Thread Starter
    Frenzied Member RudyL's Avatar
    Join Date
    Mar 2001
    Location
    Chicago
    Posts
    1,519
    Is there no way to access those through the User Interface? Kinda like it is done is VB6 (See attached)..
    Attached Images Attached Images  
    10 different ways to skin a cat and amazingly enough each and every one has the same result, the cat gets skinned! The same can be applied to code, so be nice and accept each others "preferences".

  11. #11
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Not that I'm aware of, but that doesn't mean much. Also not sure about the auto increment build thing.

  12. #12

    Thread Starter
    Frenzied Member RudyL's Avatar
    Join Date
    Mar 2001
    Location
    Chicago
    Posts
    1,519
    Originally posted by Mike Hildner
    [B]
    VB Code:
    1. form1.lblcaption.caption = App.Major & "." & App.Minor & "." & App.Revision
    Would be something like
    VB Code:
    1. Label1.Text = Application.ProductVersion
    About this... You didn't list out the form.. How would I set the label property from another form or module? I need to do something like (vb6) for1.label.caption. However, I can't figure out how to call the [form].what ever...
    10 different ways to skin a cat and amazingly enough each and every one has the same result, the cat gets skinned! The same can be applied to code, so be nice and accept each others "preferences".

  13. #13
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    If you're doing inside the class (in this case a form) that has the control you want to reference, you don't need to specify the form name, because it's assumed. However you could write it like
    VB Code:
    1. Me.Label1.Text = Application.ProductVersion

    If you're trying to do it from a different class, then you need a reference to the instance of the class you want to change.

  14. #14

    Thread Starter
    Frenzied Member RudyL's Avatar
    Join Date
    Mar 2001
    Location
    Chicago
    Posts
    1,519
    Originally posted by Mike Hildner


    If you're trying to do it from a different class, then you need a reference to the instance of the class you want to change. [/B]
    Could you give me an example of this?

    Sorry I have so many ?? I feel like I am starting all over again..
    10 different ways to skin a cat and amazingly enough each and every one has the same result, the cat gets skinned! The same can be applied to code, so be nice and accept each others "preferences".

  15. #15
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Originally posted by RudyL

    Sorry I have so many ?? I feel like I am starting all over again..
    In a way you are. It's a different animal, no doubt. But much more fun to play with, IMHO.

    Unsolited advice you can choose to ignore - first, try searching around because I know this has been discussed before. Second, make a new thread for a different subject.

    That being said, what, exactly do you want to do? Reason I ask is to me that's kind of a general question, but, as you know, there are many way to skin a cat Can you give an overview of the program flow you want to achieve?

    Mike

  16. #16
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045
    Is this what you are looking for?

    Code:
    '================================================================================
    'ENABLE ACCESS TO FORM COMPONENTS FROM OTHER PROJECT MODULES
    'Near the top of the Form code (Open the "Windows Form Designer Generated Code" section:
    
    #Region " Windows Form Designer generated code "
        Public Sub New()
            MyBase.New()
            'This call is required by the Windows Form Designer.
            InitializeComponent()
    
            'Add any initialization after the InitializeComponent() call
    
    '>>>>   ' Allow Global References to this form as "frmMain"
    '>>>>   ' This reference was set up in module "Globals"
    '>>>>   '        >>> Public frmMain as Form1 <<<
            frmMain = Me
    
        End Sub
    
    
    'Create a new Module "Globals" or else Inside your Module at the top:
    
    Module Globals ' or your own module ...
      '=================================================================
      ' Make Form1 GLOBAL as frmMain
      '-----------------------------------------------------------------
      Public frmMain As Form1
      '=================================================================
    
    
    'Now you can access the Form components inside the module
    Sub write_textbox()
      frmMain.textbox1.Text = "My Text!"
    End Sub
    
    'Note: If the Form isn't open when this is called, you will get a run time
    '      error.  Some events, such as initializing radio buttons, fire while the
    '      form is loading but before controls can be accessed in the event handler.
    
    'The same reference from inside the Form Class:
      Me.textbox1.Text = "My Text"
    'or simply
      textbox1.Text = "My Text"
    
    '================================================================================
    This is from a personal tutorial I'm writing ... I would welcome any comments or corrections.
    Blessings in abundance,
    All the Best,
    & ENJOY!

    Art . . . . Carlisle, PA . . USA

  17. #17

    Thread Starter
    Frenzied Member RudyL's Avatar
    Join Date
    Mar 2001
    Location
    Chicago
    Posts
    1,519
    Originally posted by Mike Hildner
    In a way you are. It's a different animal, no doubt. But much more fun to play with, IMHO.

    Unsolited advice you can choose to ignore - first, try searching around because I know this has been discussed before. Second, make a new thread for a different subject.

    That being said, what, exactly do you want to do? Reason I ask is to me that's kind of a general question, but, as you know, there are many way to skin a cat Can you give an overview of the program flow you want to achieve?

    Mike
    Yea, I do need to do some more reaserch.. I kind of got off topic here..

    I am just making a "First" app. I have not really done anything other than make a form that says Hello before in .NET.. In this particular one I am trying to immitate the Splash form that VB6 supplies as an example since I did not see one in .NET. I thought it would be an easy thing to do and learn..
    10 different ways to skin a cat and amazingly enough each and every one has the same result, the cat gets skinned! The same can be applied to code, so be nice and accept each others "preferences".

  18. #18

    Thread Starter
    Frenzied Member RudyL's Avatar
    Join Date
    Mar 2001
    Location
    Chicago
    Posts
    1,519
    Originally posted by Webtest
    Is this what you are looking for?

    Code:
    '================================================================================
    'ENABLE ACCESS TO FORM COMPONENTS FROM OTHER PROJECT MODULES
    'Near the top of the Form code (Open the "Windows Form Designer Generated Code" section:
    
    #Region " Windows Form Designer generated code "
        Public Sub New()
            MyBase.New()
            'This call is required by the Windows Form Designer.
            InitializeComponent()
    
            'Add any initialization after the InitializeComponent() call
    
    '>>>>   ' Allow Global References to this form as "frmMain"
    '>>>>   ' This reference was set up in module "Globals"
    '>>>>   '        >>> Public frmMain as Form1 <<<
            frmMain = Me
    
        End Sub
    
    
    'Create a new Module "Globals" or else Inside your Module at the top:
    
    Module Globals ' or your own module ...
      '=================================================================
      ' Make Form1 GLOBAL as frmMain
      '-----------------------------------------------------------------
      Public frmMain As Form1
      '=================================================================
    
    
    'Now you can access the Form components inside the module
    Sub write_textbox()
      frmMain.textbox1.Text = "My Text!"
    End Sub
    
    'Note: If the Form isn't open when this is called, you will get a run time
    '      error.  Some events, such as initializing radio buttons, fire while the
    '      form is loading but before controls can be accessed in the event handler.
    
    'The same reference from inside the Form Class:
      Me.textbox1.Text = "My Text"
    'or simply
      textbox1.Text = "My Text"
    
    '================================================================================
    This is from a personal tutorial I'm writing ... I would welcome any comments or corrections.
    If I understand this (and I probably don't) I have to inessance create an alias for the form to be accessed out side of the form?


    Let me give you a better - simplified example of what I am expecting to be able to do..

    (This is in VB6)
    VB Code:
    1. ' ModMain code
    2. Public Sub Main
    3.  
    4. frmSplash.lblVersion.caption = "Version: " & App.Major & "." & App.Minor & "." & App.Revision ' This is displayed as Version: x.x.x
    5. frmSplash.show
    6. DoEvents
    7. Call Sleep(5000)   ' Wait 5 seconds
    8. DoEvents
    9. Call UnLoad(frmSplash)
    10. DoEvents
    11.  
    12. End Sub
    10 different ways to skin a cat and amazingly enough each and every one has the same result, the cat gets skinned! The same can be applied to code, so be nice and accept each others "preferences".

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