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".
In Vb I could make a lable reflect the build version of the code by saying:
VB Code:
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".
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.
{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".
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".
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:
' Version information for an assembly consists of the following four values:
'
' Major Version
' Minor Version
' Build Number
' Revision
'
' You can specify all the values or you can default the Build and Revision Numbers
' by using the '*' as shown below:
<Assembly: AssemblyVersion("1.0.*")>
I usually just change mine to 1.2, 1.3 or 2.0 or whatever.
Is there no way to access those through the User Interface? Kinda like it is done is VB6 (See attached)..
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".
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".
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:
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.
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".
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?
'================================================================================
'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.
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".
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:
' ModMain code
Public Sub Main
frmSplash.lblVersion.caption = "Version: " & App.Major & "." & App.Minor & "." & App.Revision ' This is displayed as Version: x.x.x
frmSplash.show
DoEvents
Call Sleep(5000) ' Wait 5 seconds
DoEvents
Call UnLoad(frmSplash)
DoEvents
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".