Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Wednesday, August 10, 2011

VB-100 : To give a Message to the user

Program to give a Message to the user (Program to call a Message function Box)
Taken from VB-Tutorial CDs ...



(A)Program Design : 


(B) Property(Controls Used
  • One Command Button with Name - Command1 and Caption - Show
(C) Attaching Code to the Object :

Private Sub Command1_Click()
Dim x As Integer
x = MsgBox("Do you wish to continue..?", vbYesNoCancel)
If x = vbYes Then
MsgBox ("YES button clicked")
ElseIf x = vbNo Then
MsgBox ("NO button clicked")
Else
MsgBox ("CANCEL button clicked")
End If
End Sub


(D) Output :



Click Show .Then a message box will appear as :



There are 3 options as Yes , No and Cancel.
Click any one of them (say , Yes) .Then another box will appear as :


 
(E) Errors :

If found any errors while running your VB program, or want to put your comment about any  program , please click Comment section , to post.


      • ====================================================================
        Back to Home   &  VB
    ===========================================================

    VB-99 : Print your name on the form


    Print the Name on the form , through the message box appeared.
     Taken from VB-Tutorial CDs ...



    (A)Program Design : 


    (B) Property(Controls Used) :
    • One Command Button with Name as Command1 and Caption as Show
    (C) Attaching Code to the Object :

    Private Sub Command1_Click()
    Dim sn As String
    sn = InputBox("Enter your name to print that on the Form ", "Name", "Visual Basic")
    Print sn
    End Sub



    (D) Output :



    Click "Show".Then another Dialog Box will appear as :


    In the above Picture , Visual Basic is the default Name.We can change it , if we want...  



    Change the Name , and Click OK as per the picture given above :
    Then we can see that ; the Name is printed on the Form.
    Again , Click ,Show to add another Name.


      
    (E) Errors :

    If found any errors while running your VB program, or want to put your comment about any  program , please click Comment section , to post.


        • ====================================================================
          Back to Home   &  VB
      ===========================================================

      VB-98 : Print Even numbers upto n

      Print even numbers upto 50 (Taken from VB-Tutorial CDs ..)


      Refer Collect and List positive integers also.



      (A)Program Design : 




      (B) Property(Controls Used) :
      • One Command Button with Caption Print and Name Command1

      (C) Attaching Code to the Object :

      Private Sub Command1_Click()
      Dim counter As Integer
      counter = 0
      While counter < 50
      counter = counter + 2
      Print counter
      Wend
      End Sub

      (D) Output :




      (E) Errors :
       If found any errors while running your VB program, please note it on Comment section.
      ====================================================================
      =========================================================

      VB-97 : Print Multiplication Table

      Print a multiplication table for a given number.



      (A)Program Design : 




      (B) Property(Controls Used) :
      • One Label with Caption Enter a number to print Multiplication Table
      • One TextBox with Name-Text1 and Text Property is Blank
      • One Command Button with Name-Command1 and Caption -Print

      C) Attaching Code to the Object :

      Private Sub Command1_Click()
      Dim counter, n, p As Integer
      n = Val(Text1.Text)
      For counter = 1 To 10
      p = n * counter
      Print n; " x "; counter; " = "; p
      Next counter
      End Sub




      (D) Output :


      Such a simple program and the Powerful Output..Right..?

      (E) Errors :


      If found any errors while running your VB program, or want to put your comment about any  program , please click Comment section , to post.


          • ====================================================================
            Back to Home   &  VB
        ===========================================================

        VB-96 : Changing Color as per the entered Number


        Changing color of form according to the entered number.

        Refer Change the background color of the form and Color changing using Timer



        (A)Program Design : 


        (B) Property(Controls Used) :
        • One Label with Caption Enter a Number (1 to 5) , Autosize-True , Backstyle - Transparent
        • One TextBox (Name-Text1 , Text Property is Blank)
        • One Command Button with Caption-Change and Name - Command1

        (C) Attaching Code to the Object :

        Private Sub Command1_Click()
        Dim n As Integer
        n = Val(Text1.Text)
        Select Case n
        Case 1
            Form1.BackColor = vbRed
        Case 2
            Form1.BackColor = vbGreen
        Case 3
            Form1.BackColor = vbBlue
        Case 4
            Form1.BackColor = vbYellow
        Case Else
            Form1.BackColor = vbWhite
        End Select
        End Sub

        (D) Output :


        ===================================================================================

        ASSIGNMENT :

        Suppose , if you want to include another colour, and you dont know the name of that colour as given below ,
         
        Then what will you do ???



        This is your assignment..

        If failed , see the comment section...to know the answer.

            • ====================================================================
              Back to Home   &  VB
          ===========================================================

          VB-95 : The number of digits in the entered Number

          Enter a Number.The output will say the number of digits in the number.

          Refer the same type of more complicatedprograms from  these four :
          Number of characters in a given string , 
          Total words,Characters,sentence,length of ...,
          Occurrence of a String 
          Count Blanks,Tabs,etc in a String   etc.


          (A)Program Design : 


          (B) Property(Controls Used) :
          • 2 Labels with Caption Enter a Number and You entered.
          • One More Label with Name Label3 and with No Caption (For your understanding , I am put the caption here as Label3)
          • One Command Button with Name-Command1 and Caption - Print
          (If we remove the Caption from Label3 , the form should look like as given below :)


          (C) Attaching Code to the Object :



          Private Sub Command1_Click()
          Dim n As Integer
          n = Val(Text1.Text)
          If n < 10 Then
          Label3.Caption = "a One Digit Number"
          ElseIf n < 100 Then
          Label3.Caption = "a Two Digit Number"
          ElseIf n < 1000 Then
          Label3.Caption = "a Three Digit Number"
          ElseIf n < 10000 Then
          Label3.Caption = "a Four Digit Number"
          ElseIf n < 100000 Then
          Label3.Caption = "a Five Digit Number"
          Else
          Label3.Caption = "A Number with more than Five Digit"
          End If
          End Sub



          (D) Output :

          ====================================================================

          Assignment :


          Here, I used 3 labels , and 3 Text Boxes and One Command Button (Print). Text Boxes are used to display the entered number and the number of digits.

          The output of the screen is :



          Do it yourself............

          or, see the comment section for the answer.

              • ====================================================================
                Back to Home   &  VB
            ===========================================================