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

Saturday, July 23, 2011

VB-59 : Concatenate 2 strings and find its length

Write an event procedure and develop an application to intake 2 strings,concatenate them and find the length of the resultant string.

(A)Program Design : 





(B) Property(Controls Used) :

  • 3 Text Boxes with name Text1,Text2,Text3 respectively.
  • 1 Label with Caption "First String+Second String" and name Label1
(C) Attaching Code to the Object :


Private Sub Text1_Change()
Text3 = Text1.Text + "" + Text2.Text
End Sub
Private Sub Text2_Change()
Text3 = Text1.Text + "" + Text2.Text
End Sub



(D) Output :




Find the Length..? Do as your homework...Or , Click VB-74 : Resultant Length of 2 concatenated Strings...
===============================================
===============================================

VB-58 : Design a Menu Bar

Using menu editor, design a menu bar that contains two titles "Colors" and "Exit".
The colors menu has menu item "Fill Color" .
When the Fill Color is clicked another menu pops up with a list of colors (Red,Blue,Green).This is the sub-menu of the Fill Color.
Upon selecting the particular color the form should fill with that color.
Upon selecting the Exit , the application should be terminated.
===============================================
Refer Program Using Menu Bar & Creating Tool Bar with Click Event 


Select Tools--> Menu Editor and create menus as per given below :




You can watch this Video to know about adding Menu Bar into our form.


     (A)Program Design : 





(B) Property(Controls Used) :

No
Caption
Name
Index
1
Color
mnu_color

  1a
      Fill Color
mnu_sub_Fill

   1a(1)
           Red
mnu_sub_color
0
   1a(2)
           Blue
mnu_sub_color
1
   1a(3)
          Green
mnu_sub_color
2
2
Exit
mnu_exit



  • Color & Exit are main menus.
  • Fill color is the sub menu of Color
  • Red,Blue,Green are the sub menus of Fill color
(C) Attaching Code to the Object :



Private Sub mnu_exit_Click()
End
End Sub
Private Sub mnu_sub_color_Click(Index As Integer)
Select Case Index
Case 0
Form1.BackColor = vbRed
Case 1
Form1.BackColor = vbBlue
Case 2
Form1.BackColor = vbGreen
End Select
End Sub

Refer Create a Menu as per the format given also.
====================================================================
=========================================================

VB-57 : Calculations using Grid control

Using the Grid control write a program that displays sum,difference,product and quotient of numbers (ranging from 1 to 10) in the respective cells upon selection of particular operation.
(Note : Place 4 command buttons for operations choice & a grid control)


Click  Simple Programs(3) to get an idea about Calculation.


Refer The four calculations  & .Simple Calculator also


(A)Program Design : 


(B) Property(Controls Used) :
  • 2 Labels with Captions Number1 & Number2
  • 2 TextBoxes (Name Text1 with index 0&1 :- So that, the name of the 2 TextBoxes will be Text1(0) & Text1(1)
  • Select Project-->Components-->Microsoft Fles Grid Control 6.0 to add a Grid (Name-Grid1,Fixed Row-1,Fixed Column-0,Rows-5,Columns-2)
  • 4 Command Buttons with Name Command1  with index 0,1,2 & 3 (So that Name will be Command1(0),Command1(1),Command1(2) and Command1(3) and Captions as Sum,Quotient,Product and Difference 

(C) Attaching Code to the Object :



Private Sub Command1_Click(Index As Integer)
Dim ans As Single
Select Case Index
Case 0
ans = Val(Text1(0).Text) + Val(Text1(1).Text)
Case 1
ans = Val(Text1(0).Text) / Val(Text1(1).Text)
Case 2
ans = Val(Text1(0).Text) * Val(Text1(1).Text)
Case 3
ans = Val(Text1(0).Text) - Val(Text1(1).Text)
End Select
Grid1.Col = 1
Grid1.Row = Index + 1
Grid1.Text = ans
End Sub
Private Sub Form_Load()
Grid1.Row = 0
Grid1.Col = 0
Grid1.Text = "Operation"
Grid1.Col = 1
Grid1.Text = "Result"
Grid1.Row = 1
Grid1.Col = 0
Grid1.Text = "Sum"
Grid1.Row = 2
Grid1.Text = "Quotient"
Grid1.Row = 3
Grid1.Text = "Product"
Grid1.Row = 4
Grid1.Text = "Difference"
End Sub
Private Sub Text1_Change(Index As Integer)
Dim n As Single
n = Val(Text1(Index).Text)
If n < 0 And n > 10 Then
MsgBox "Number should between 1 to 10 only"
Text1(Index).SetFocus
End If
End Sub



(D) Output :


Give Numbers as 8 & 2 , then click the 4 command buttons in order to display the result inside the Grid.

Refer this Video Tutorial
====================================================================
=========================================================

VB-56 : Change the background color of the form

Write an event procedure to change the background color of the form by selecting one of 3 color options.
(Note : Use control array with 3 option buttons)


(Refer another type of colour changing program "Colour changing using Timer" and Changing Color as per the entered Number)



(A)Program Design : 



(B) Property(Controls Used) :
  • One Label to Entitle the program "Select Form's Background color"
  • 3 OptionButtons(Captions as Red,Green & Blue) with name Option1 (Same name creates a control array with index 0,1 & 2 .That is the name of the OptionButtons are : Option1(0),Option1(1) and Option1(2)
  • Form name is Form1




(C) Attaching Code to the Object :

Private Sub Option1_Click(Index As Integer)
Select Case Index
Case 0
Form1.BackColor = vbRed
Case 1
Form1.BackColor = vbGreen
Case 2
Form1.BackColor = vbBlue
End Select
End Sub


(D) Output :


(have any error in output ?)
====================================================================
=========================================================

VB-55 : Displaying Day for a given date

Write an event procedure to display the day for a given date.

Refer Displaying Current Date and Time also.

(A)Program Design : 
To set Date, we need a controll called DtPicker.
To add DtPicker , select Project--> Components--> Microsoft Window common control-2.6.0




B) Property(Controls Used) :

  • 2 Labels (Label1,Label2) with Captions as Select Date and Day of the Date is
  • One Text Box (Name-Text1) for displaying the Day 
  • The control DtPicker (Name DtPicker1) near to label1 "Select Date"


(C) Attaching Code to the Object :
Private Sub DTPicker1_Change()
Select Case Weekday(DTPicker1)
Case 1: Text1.Text = "Sunday"
Case 2: Text1.Text = "Monday"
Case 3: Text1.Text = "Tuesday"
Case 4: Text1.Text = "Wednesday"
Case 5: Text1.Text = "Thursday"
Case 6: Text1.Text = "Friday"
Case 7: Text1.Text = "Saturday"
End Select
End Sub
Private Sub Form_Load()
DTPicker1_Change
End Sub


(D) Output :



24th  July-2011 is Sunday.

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