Sunday 23 September 2012

Simple VB Programs


1. Program Using The Check Box, Option Button, Frame

Control
Property
Value
Form
Caption
Check & option
Label 1
Caption
Enter text here
Label 1
Auto size
True
Label 1
Font
Bold,8
Text 1
Text
Empty
Text 1
Multi line
True
Text 1
Scroll bar
3-both
Frame 1
Caption
Case
Frame 2
Caption
Effects
Option 1
Caption
Upper
Option 2
Caption
Lower
Check 1
Caption
Strikethrough
Check 2
Caption
Underline
Check 3
Caption
bold
Command 1
Caption
exit

 
DESIGN VIEW:




 CODING:
Private Sub Check1_Click()
If Check1.Value = 1 Then
Text1.Font.Strikethrough = True
Else
Text1.Font.Strikethrough = False
End If
End Sub

Private Sub Check2_Click()
If Check2.Value = 1 Then
Text1.Font.Underline = True
Else
Text1.Font.Underline = False
End If
End Sub

Private Sub Check3_Click()
If Check3.Value = 0 Then
Text1.Font.Bold = False
Else
Check3.Value = 1
Text1.Font.Bold = True
End If
End Sub

Private Sub Command1_Click()
End
End Sub

Private Sub Form_Load()
Option2.Value = True
End Sub

Private Sub Option1_Click()
If Option1.Value = True Then
Text1.Text = UCase(Text1)
End If
End Sub

Private Sub Option2_Click()
If Option2.Value = True Then
Text1.Text = LCase(Text1)
End If
End Sub





 2. Program using the ListBox,ComboBox, and TextBox

Control
Property
Value
Label 1
caption
Enter text here
Label 1
Auto size
true
Label 1
font
Bold,10
Text 1
text
empty
Text 1
Multi line
true
Text 1
scrollbar
3-both
Label 2
Caption
Font name
Label 3
Caption
Font size
List 1
List
EMPTY
Combo 1
Caption
EMPTY
Command 1
Text
&exit




DESIGN VIEW :



 

CODING :

Private Sub Combo1_Click()
Text1.FontSize = Val(Combo1.Text)
End Sub
Private Sub Command1_Click()
End
End Sub

Private Sub Form_Load()
Dim i As Integer
For i = 1 To Screen.FontCount - 1
List1.AddItem Screen.Fonts(i)
Next i
For i = 2 To 50 Step 2
Combo1.AddItem i
Next i
End Sub

Private Sub List1_Click()
Text1.FontName = List1.Text
End Sub

 



3. Program for creating a Log-in Form

Control
Property
Value
Label 1
Caption
Username
Label 2
Caption
Password
Text 1
Caption
EMPTY
Text 2
Caption
EMPTY
Command 1
Caption
Ok
Command 2
Caption
Cancel
Form 2


Label 1
Caption
welcome to srinu

DESIGN VIEW :




CODING :

Private Sub Command1_Click()
If Text1.Text = "srinu" And Text2.Text = "college" Then
Form2.Show
Form1.Hide
Else
MsgBox "invalid username & password"
Text1.Text = ""
Text2.Text = ""
End If
End Sub

Private Sub Command2_Click()
End
End Sub

No comments:

Post a Comment

Oracle Reserved Words

Oracle  Reserved Words The following words are reserved by Oracle. That is, they have a special meaning to Oracle and so cannot be redefi...