Tuesday, March 30, 2010

Setting Object Properties at Run Time in VB6 Programming



In the previous posting you have learnt how to set object properties at design time, by clicking the object you want, then change/set the value of property in the properties window. In this posting I'll write how to set/change property value at run time (when program running). And also I'll give you a sample program (code).

Below is the syntax how to set an object property at run time:
Object.Property = Expression

For example:
Below statement will set Caption of lblName with "John Smith" at run time.
lblName.Caption = "John Smith"

However not all object properties can be set their values at run time, because some object properties can be set just at design time. In the next posting maybe I'll write lists of which object properties that can be set just at design time, which ones that can be set just at run time, and which ones that can be set both at design time and run time.


Monday, March 29, 2010

Setting Object Properties at Design Time in VB6



Setting Properties of Object in VB6 programming

In the previous posting I've written that you can set the properties of an object at design time. The properties settings that you establish at design time are used as the initial settings each time your application runs. You can set the object properties by using Properties window.

Although it is not a must, because you set the properties of course according to your need. But some properties usually you set them at design time, such as:
BackStyle
BorderStyle
Caption
Enabled
FillColor
FillStyle
Name
Visible

How to set the value of property at design time, you can follow below steps:
  • At the Form Designer window, select the form or control which you want to set the property by clicking it.
    Visual Basic will activate the form or control, and displays the property for the object.
  • In the Propertis window, select the property you want to set.
  • Type or select the property setting value you want.
    Some property values can be selected from the list, but others must be typed.


  • Sunday, March 28, 2010

    A Tips to Create a Function to Convert Numbers into Roman Numerals



    To create a number of letters we often use roman numerals to indicate the month of making the letter.For example, the letter number is '001 / Int/III/2010' where the symbol 'III' indicates that the letter was made in March 2010.

    For this we need a function that can convert an integer number from 1 to 12 into roman numerals. In the Visual Basic programming, we can easily create such a function. Well, here we'll show an example program to create such functions, as well as examples of how to use it.

  • First open your VB program and select standard exe form




  • Click the View menu




  • Click the Code menu






  • Write the Visual Basic (VB) program code below
    Function IToR(i As Integer) As String Dim s As String s = "I II III IV V VI VII VIIIIX X XI XII " IToR = Mid(s, (i - 1) * 4 + 1, 4) End Function





  • Click the View menu




  • Click the Object menu




  • Put two label controls, two textboxes and a CommandButton to the form




  • Change the Caption of first label into 'Month'




  • Change the Caption of second label into 'Roman Numeral'




  • Change the name of the first textbox into 'txtMonth'




  • Change the name of the second textbox into 'txtRomNum'




  • Remove texts on the first and second textboxes




  • Change the name of the CommandButton into 'cmdConvert'




  • Change the CommandButton caption into 'Convert'
    So your Screen design will look like the image below:





  • Double click CommandButton 'Convert'




  • Write below Visual Basic (VB) program coding
    Private Sub cmdConvert_Click() txtRomNum.Text = IToR(Val(txtMonth.Text)) End Sub

    Okay, you have completed the program
    Now it's time to test





    • Run your program
  • Type a number such as 8 in the first textbox




  • Click CommandButton 'Convert'
    Consider the results





  •