Visual Basic
Visual Basic
End Sub
Private Sub cmdSub_Click()
val1 = Val(display.Text)
opt = "-"
display.Text = ""
End Sub
Private Sub CommandClear_Click()
display.Text = ""
End Sub
Private Sub digit_Click(Index As Integer)
If cleardisp Then
display.Text = ""
cleardisp = False
End If
display.Text = display.Text + digit(Index).Caption
End Sub
Private Sub Form_Load()
End Sub
Output:
Name: Aadil Hussain
If (Check3.Value = 1) Then
Text1.FontUnderline = True
Else
Text1.FontUnderline = False
End If
End Sub
Private Sub Form_Load()
End Sub
Private Sub Option1_Click()
Text1.FontSize = 10
End Sub
Private Sub Option2_Click()
Text1.FontSize = 12
End Sub
Private Sub Option3_Click()
Text1.FontSize = 14
End Sub
Private Sub Option4_Click()
Text1.ForeColor = vbBlue
End Sub
Private Sub Option5_Click()
Text1.ForeColor = vbGreen
End Sub
Private Sub Option6_Click()
Text1.ForeColor = vbRed
End Sub
Name: Aadil Hussain
Output
Name: Aadil Hussain
Output:
Name: Aadil Hussain
Option Explicit
Dim documentforms(10) As New Form1
Private Sub arrange_Click()
arrange 2
End Sub
Private Sub cascade_Click()
arrange 0
End Sub
Private Sub FormOpen_Click()
Dim i As Integer
For i = 0 To 9
documentforms(i).Show
documentforms(i).Caption = "document" & Format(i)
documentforms(i).BackColor = QBColor(Rnd * 14 + 1)
Next i
End Sub
Private Sub FormsClose_Click()
Name: Aadil Hussain
Dim i As Integer
For i = 0 To 9
Unload documentforms(i)
End Sub
Private Sub horizontal_Click()
arrange 1
End Sub
Name: Aadil Hussain
OUTPUT:
Else
newform.txtpad.FontBold = True
End If
End Sub
Private Sub mnubolditalic_Click()
newform.txtpad.FontBold = True
newform.txtpad.FontItalic = True
End Sub
Private Sub mnucolor_Click()
CommonDialog1.ShowColor
newform.txtpad.BackColor = CommonDialog1.Color
End Sub
Private Sub mnueditcopy_Click()
Clipboard.SetText mdiform1.ActiveForm.txtpad.SelText
mnueditpaste.Enabled = True
standard.Buttons("paste").Enabled = True
End Sub
Private Sub mnueditcut_Click()
Clipboard.SetText mdiform1.ActiveForm.txtpad.SelText
mdiform1.ActiveForm.txtpad.SelText = ""
mnueditpaste.Enabled = True
standard.Buttons("paste").Enabled = True
End Sub
Private Sub mnueditpaste_Click()
mdiform1.ActiveForm.txtpad.SelText = Clipboard.GetText
End Sub
Private Sub mnueditselall_Click()
mdiform1.ActiveForm.txtpad.SelStart = 0
mdiform1.ActiveForm.txtpad.SelLength = Len(mdiform1.ActiveForm.txtpad.Text)
mdiform1.ActiveForm.txtpad.SetFocus
End Sub
Private Sub mnufileexit_Click()
End
End Sub
Private Sub mnufilenew_Click()
Set newform = New frmmain
newform.txtpad.Text = ""
newform.Caption = "untitled" & Str(Forms.Count - 2)
mnueditcut.Enabled = True
mnueditcopy.Enabled = True
mnufilesaveas.Enabled = True
mnueditselall.Enabled = True
Name: Aadil Hussain
standard.Buttons("cut").Enabled = True
standard.Buttons("copy").Enabled = True
standard.Buttons("save").Enabled = True
sbarnpad.Panels("file").Text = mdiform1.ActiveForm.Caption
newform.Show
End Sub
Private Sub mnufileopen_Click()
CommonDialog1.ShowOpen
End Sub
Private Sub mnufilesaveas_Click()
CommonDialog1.ShowSave
End Sub
Private Sub mnuitalic_Click()
If newform.txtpad.FontItalic = True Then
newform.txtpad.FontItalic = False
Else
newform.txtpad.FontItalic = True
End If
End Sub
Private Sub mnuregular_Click()
newform.txtpad.FontBold = False
newform.txtpad.FontItalic = False
End Sub
Private Sub mnuunderline_Click()
If newform.txtpad.FontUnderline = True Then
newform.txtpad.FontUnderline = False
Else
newform.txtpad.FontUnderline = True
End If
End Sub
Private Sub mnuwincas_Click()
mdiform1.Arrange vbCascade
End Sub
Private Sub mnuwinth_Click()
mdiform1.Arrange vbTileHorizontal
End Sub
Private Sub standard_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Key
Case "new"
mnufilenew_Click
Case "open"
mnufileopen_Click
Name: Aadil Hussain
Case "save"
mnufilesaveas_Click
Case "cut"
mnueditcut_Click
Case "copy"
mnueditcopy_Click
Case "paste"
mnueditpaste_Click
End Select
End Sub
Private Sub Timer1_Timer()
Dim num As Integer
num = Forms.Count - 2
If num > 0 Then
sbarnpad.Panels("file").Text = mdiform1.ActiveForm.Caption
Else
sbarnpad.Panels("file").Text = "enjoy mdi notepad"
mnueditpaste.Enabled = False
mnueditcut.Enabled = False
mnueditcopy.Enabled = False
mnueditselall.Enabled = False
mnufilesaveas.Enabled = False
mnufilesaveas.Enabled = False
standard.Buttons("cut").Enabled = False
standard.Buttons("copy").Enabled = False
standard.Buttons("paste").Enabled = False
standard.Buttons("save").Enabled = False
End If
End Sub
Name: Aadil Hussain
Output:
Name: Aadil Hussain
Dim a As Variant
Private Sub Command1_Click()
RichTextBox1.SelBold = True
End Sub
Private Sub Command10_Click()
MsgBox (RichTextBox1.SelStart)
End Sub
Private Sub Command11_Click()
RichTextBox1.SelLength = Len(RichTextBox1.Text)
MsgBox (RichTextBox1.SelLength)
End Sub
Private Sub Command2_Click()
RichTextBox1.SelItalic = True
End Sub
Private Sub Command3_Click()
RichTextBox1.SelBold = False
RichTextBox1.SelItalic = False
End Sub
Private Sub Command4_Click()
Name: Aadil Hussain
Output:
Design Window
Option Explicit
Dim a, b, l, t, c, col As Integer
Private Sub exit_Click()
End
End Sub
Private Sub Form_Load()
l=0b=0t=0
Timer1.Enabled = False
Text1.Text = " VISUAL BASIC"
Text1.FontBold = True
Text1.BackColor = vbRed
Text1.ForeColor = vbYellow
Text1.FontSize = "20"
Form5.Caption = "timer"
Form5.WindowState = 2
End Sub
Private Sub start_Click()
Timer1.Enabled = True
End Sub
Name: Aadil Hussain
Output:
Name: Aadil Hussain
Design Window
If rectangle.FillStyle = 0 Then
rectangle.FillColor = vbGreen
ElseIf cicle.FillStyle = 0 Then
cicle.FillColor = vbGreen
ElseIf Square.FillStyle = 0 Then
Square.FillColor = vbGreen
End If
End Sub
Private Sub abcolorred_Click()
abcolorblue.Checked = False
abcolorgreen.Checked = False
abcolorred.Checked = True
abcoloryellow.Checked = False
If rectangle.FillStyle = 0 Then
rectangle.FillColor = vbRed
ElseIf cicle.FillStyle = 0 Then
cicle.FillColor = vbRed
ElseIf Square.FillStyle = 0 Then
Square.FillColor = vbRed
End If
End Sub
Private Sub abcoloryellow_Click()
abcolorblue.Checked = False
abcolorgreen.Checked = False
abcolorred.Checked = False
abcoloryellow.Checked = True
If rectangle.FillStyle = 0 Then
rectangle.FillColor = vbYellow
ElseIf cicle.FillStyle = 0 Then
cicle.FillColor = vbYellow
ElseIf Square.FillStyle = 0 Then
Square.FillColor = vbYellow
End If
End Sub
Private Sub abfileexit_Click()
End
End Sub
Private Sub abshapecircle_Click()
abshapecircle.Checked = True
abshapesquare.Checked = False
abshaperectangle.Checked = False
cicle.FillStyle = 0
Name: Aadil Hussain
rectangle.FillStyle = 1
Square.FillStyle = 1
rectangle.FillColor = &H0&
Square.FillColor = &H0&
End Sub
Private Sub abshaperectangle_Click()
abshapecircle.Checked = False
abshapesquare.Checked = False
abshaperectangle.Checked = True
cicle.FillStyle = 1
rectangle.FillStyle = 0
Square.FillStyle = 1
rectangle.FillColor = &H0&
Square.FillColor = &H0&
End Sub
Private Sub abshapesquare_Click()
abshapecircle.Checked = False
abshapesquare.Checked = True
abshaperectangle.Checked = False
cicle.FillStyle = 1
rectangle.FillStyle = 1
Square.FillStyle = 0
rectangle.FillColor = &H0&
Square.FillColor = &H0&
End Sub
Name: Aadil Hussain
Output:
Name: Aadil Hussain
Design Window
Option Explicit
Dim responce As Integer
Private Sub Command1_Click()
Data1.Recordset.AddNew
Text1.SetFocus
End Sub
Private Sub Command2_Click()
responce = MsgBox("do you want to delete the record", vbYesNo)
If responce = vbYes Then
Data1.Recordset.Delete
Data1.Recordset.MoveFirst
End If
End Sub
Private Sub Command3_Click()
Data1.Recordset.Edit
Data1.Recordset.Update
End Sub
Name: Aadil Hussain
Output:
Name: Aadil Hussain
Design Window
Output:
Name: Aadil Hussain
Design Window
Output:
Name: Aadil Hussain
16.Wap to create a file and write /read to /from file through file
handling.
Design Window
Output:
Name: Aadil Hussain
17.Wap to create a file and write /read to /from file through file handling
using random access concept.
Design Window
Module Coding
Type record
name As String * 50
number As String * 50
End Type
Dim writedata(1 To 50) As record
Dim readdata(1 To 50) As record
Dim totalrecords As Integer
Private Sub Command1_Click()
writedata(1).name = Text1.Text
writedata(1).number = Text2.Text
totalrecords = 1
Open "c:\records.doc" For Random As #1 Len = Len(writedata(1))
For intloopindex = 1 To totalrecords
Put #1, , writedata(intloopindex)
Next intloopindex
Close #1
End Sub
Private Sub Command2_Click()
Dim intloopindex As Integer
Name: Aadil Hussain
Output:
Name: Aadil Hussain
Design Window
End Sub
Output:
Name: Aadil Hussain
Design Window
End If
Name: Aadil Hussain
Form1.Hide
frmole.OLE1.InsertObjDlg
If frmole.OLE1.Class <> " " Then
frmole.Command1.Enabled = 2
End If
Unload Form1
End Sub
Private Sub Command2_Click()
Unload frmtype
End Sub
Private Sub Command1_Click()
With frmole.OLE1
.Height = frmole.oleheight
.Width = frmole.olewidth
End With
If Option1.Value = True Then
frmole.OLE1.SizeMode = 1
Else
frmole.OLE1.SizeMode = 2
End If
If Option3.Value Then
frmole.OLE1.OLETypeAllowed = 1
Else
frmole.OLE1.OLETypeAllowed = 0
End If
Form1.Hide
frmole.OLE1.InsertObjDlg
If frmole.OLE1.Class <> " " Then
frmole.Command1.Enabled = 2
End If
Unload Form1
End Sub
Private Sub Command2_Click()
Unload frmtype
End Sub
Option Explicit
Public oleheight As Integer
Public olewidth As Integer
Private Sub Command1_Click()
Form1.Show
End Sub
Private Sub Command3_Click()
Name: Aadil Hussain
End
End Sub
Private Sub Form_Load()
oleheight = OLE1.Height
olewidth = OLE1.Width
End Sub
Name: Aadil Hussain
Output: