Building Windows Application (Address Book) - Part III
Building the User Interfaces
In the previous sections, we saw the development of Login form which involved various controls like Error Provider, Help Provider and many other things. In this section we will see the development of the Splash screen for our address Book.
Before getting to the actual development of Windows Application, let me tell you few more tips in VB.NET.
Today's tip
I am going to give two tips today. Probably, you may even laugh at it. Ok, Let me take a chance.
First Tip
Let me ask a question to the developers who have come from the VB background. I want a Text box in VB6.0 which should enter only in Capital Letters (what ever the user enters should be entered in Capitals).
You will be writing the following code in the KeyPress event of the Textbox.
' This is VB6.0 Code Private Sub Text1_KeyPress(KeyAscii As Integer) KeyAscii = Asc(UCase(Chr(KeyAscii))) End Sub
What actually you are doing in the above code is you are getting the key, which is pressed, and converting that into Capitals.
The same can also be done in VB.NET (With slight modification). But if you can spend some time and check in the property window you will be finding one property called "CharacterCasing" which takes any of these three values
You can assign any of these three values to the above-mentioned properties to get your desired output. By using this property, I don't need to write any code, just changing the CharacterCasing to Upper is enough. (This property can also be used to set the Textbox to take the entries in Lowercase.)
Second Tip
The Second Tip which I am going to tell is also every similar to the first one. I am going to tell about one of the properties of the textbox in VB.NET. Before that lets see how to restrict the Input Character length for a Textbox in VB6.0. We will be writing the following code in the KeyPress event of the Textbox.
Private Sub Text1_KeyPress(KeyAscii As Integer) If Len(Text1.Text) = 6 And KeyAscii <> 8 Then KeyAscii = 0 End If End Sub
Actually what we are doing in the above code is, we are checking whether the length of the text contained in the Textbox is 6, if it is so we are blocking the user from further entering any character by the statement KeyAscii = 0
And I am checking KeyAscii <> 8 , I need to check whether the key pressed is Backspace I should allow that, since I am not adding any new characters, but I am just going to remove some characters.
The same can also be done in VB.NET. But, we have a Property called MaxLength which does what we did in the above VB6.0 Code. Like this .NET has provided us with lot of properties and controls which makes our job much more easier. But we need to explore a lot and learn more.
Ok then, lets get back the development of the Address Book Application.
Development of the Splash Screen
In VB6.0 we had a separate form type called "Splash Screen". But here in VB.NET, we don't have that, Instead we need to design the form like a splash screen. Even, it is same in VB6.0 also, in which VB6.0 did all the required thing to make the form a splash screen.
Actually, this form is of no use, but still they can be used for two purposes.
1. For hiding the time taken for the application to Load. For example, the application may be requiring lot of data to be loaded during the startup; this may increase the application startup time considerably. In order to hide that this splash screens can be utilized.
2. For displaying the Information about the company and the product. In our project, I am going to use this splash screen for the second reason only.
Building the Splash Screen
Add a new form called "frmSplashScr". Then change the "FormBorderStyle" property to "None" and set the "StartPosition" property of the form to CenterScreen. And remaining, you can design your own. Don't think that I am just stopping only with this. I am going to tell more.
The splash screen which I have designed look like this.

If you see, I have displayed the company name, product name and the version. I have not hard corded them in the form itself. I have placed three Labels called lblCompany, lblApplicationTitle and lblVersion.
Every EXE file will have some properties in General, like EXE Name, Company name, Product Version etc., They can be seen by viewing the properties of the EXE. For example, see the figure below shows the properties of the one of the windows standard EXE which everyone will be familiar with "Notepad".

(Right click on the EXE and get into properties, and select the Version tab, there you can see all the properties of that EXE) As we all know, the output of the Windows Application is going to be an EXE. So, we can also set these properties to our EXE. But How? Will be a big question in your mind now. We will discuss about that, now.
I hope you all know that an EXE is also called as an Assembly or to put it in a correct way "An assembly is nothing but the output of the .NET Languages, Which can be an EXE or a DLL, where the windows application, console application and windows service project results in an EXE, all other project results in a DLL".
Just take a close look at the Project structure in the solution explorer, what are the things that you find there. You will be having the forms, modules and class, which you have added. Apart from them you will also be having a class called AssemblyInfo. What is that for. This is the file which is going to store the information about the assembly like application name, product version, company name etc. Just open that and see you will be finding the following tags in that file.
<Assembly: AssemblyTitle("Address Book")> 'EXE Title <Assembly: AssemblyDescription("Address Book Developed in VB.NET using the Resource File to store data.")> 'EXE Description <Assembly: AssemblyCompany("XYZ Company")> 'Company Name <Assembly: AssemblyProduct("AddressBook")> 'Product Name <Assembly: AssemblyCopyright("Sadhasivam")> ' Copy Rights <Assembly: AssemblyTrademark("")> <Assembly: CLSCompliant(True)> <Assembly: Guid("84095DF5-C5E9-4153-8F09-B71D18E1F2D6")> <Assembly: AssemblyVersion("1.0.*")> 'EXE Version.
Whereas each tag represents one property of the Assembly. We can edit the values passed as the parameters.
If you see the above tags I have modified them.
Once you build the EXE, the compiler reads the information from this file and binds these properties to the EXE. Which can be accessed via the property windows of the exe. Now, lets see how can they be read using the VB.NET program.
Application object and its usage
Application object gives almost all the information about the EXE. We can get the startup path of the EXE and many other things. And also we can access the assembly information.
Code used in the Splash Screen Code, (Write the following code in the Form_load event.
lblCompany.Text = Application.CompanyName lblApplicationTitle.Text = Application.ProductName lblVersion.Text = Application.ProductVersion
And we have several other properties in the Application class. You can try them, if you find any difficulty in using them, feel free to drop me a mail. With this lets end up this article. Let me speak with you in the next article, will bringing a lot of tips in the next section.
Click here to download the source code.
If you have any queries, doubt or suggestion to improve, please drop me a mail at asksadha@yahoo.com or asksadha@hotmail.com.
Visit http://sadhasivam.t35.com to know more about me.
|
| Author: Sathish 27 Aug 2004 | Member Level: Bronze Points : 0 |
i saw ur notes and i'm not able to see any property of the text box window as "character casing". if u can explain that in detail i'll appreciate that
|