bca 5th sem
-
Upload
ranaindia2011 -
Category
Documents
-
view
317 -
download
2
description
Transcript of bca 5th sem
/*Program to count digits of a given number*/
Program to count digits of a given number
Private Sub cmdDigits_Click()
'variables declaration
Dim lngNum As Long
Dim intCounter As Integer 'Fetch the number from text box (txtNum) into lngNum
lngNum = Val(txtNum.Text) 'obtaining the individual digits from number and count
While lngNum > 0
lngNum = lngNum / 10
intCounter = intCounter + 1
Wend 'Print the output
lblOutput.Caption = "The total digits in the given number is " & intCounter
End SubProgram to find whether the give character is vowel, special character,
Capital, small or digit
Private Sub cmdOk_Click()
'variable declaration
Dim strInput As String, bytAsc As Byte 'fetch character from text box (txtInput) into strInput
strInput = txtInput.Text
bytAsc = Asc(strInput) 'check if given input is small character
If bytAsc >= 65 And bytAsc = 48 And bytAsc intArray(intRow, intNext) Then
intTemp = intArray(intRow, intCol)
intArray(intRow, intCol) = intArray(intRow, intNext)
intArray(intRow, intNext) = intTemp
End If
Next intNext
Next intCol
Next intRow
'Print The Output
For intRow = 0 To 2
For intCol = 0 To 2
Print Space(8) & intArray(intRow, intCol);
Next intCol
Print: Print
Next intRow
End Sub
Program to perform all common task of common dialog box
Private Sub Form_Resize()
rt1.Width = Form1.ScaleWidth
rt1.Height = Form1.ScaleHeight
End Sub
Private Sub mnuEditCopy_Click()
Clipboard.SetText (rt1.SelRTF)
End Sub
Private Sub mnuEditCut_Click()
Clipboard.SetText (rt1.SelRTF)
rt1.SelRTF = ""
End Sub
Private Sub mnuEditPaste_Click()
rt1.SelRTF = Clipboard.GetText
End Sub
Private Sub mnuFileExit_Click()
Unload Me
End Sub
Private Sub mnuFileNew_Click()
rt1.TextRTF = ""
End Sub
Private Sub mnuFileOpen_Click()
On Error Resume Next
cd1.ShowOpen
rt1.LoadFile (cd1.FileName)
End Sub
Private Sub mnuFileSave_Click()
On Error Resume Next
cd1.ShowSave
rt1.SaveFile (cd1.FileName)
End Sub
Private Sub mnuFormatFont_Click()
On Error Resume Next
cd1.Flags = cdlCFEffects Or cdlCFBoth
cd1.ShowFont
rt1.SelFontName = cd1.FontName
rt1.SelColor = cd1.Color
rt1.SelBold = cd1.FontBold
rt1.SelItalic = cd1.FontItalic
rt1.SelFontSize = cd1.FontSize
rt1.SelStrikeThru = cd1.FontStrikethru
rt1.SelUnderline = cd1.FontUnderline
End SubProgram to rotate 4 images
Option Explicit
Dim strPath1 As String, strPath2 As String, strPath3 As String, strPath4 As String
Private Sub Image1_Click()
End Sub
Private Sub cmdStartStop_Click()
Static blnState As Boolean
blnState = Not blnState
Timer1.Enabled = blnState
If blnState Then
cmdStartStop.Caption = "Stop Rotation"
Else
cmdStartStop.Caption = "Start Rotation"
End If
End Sub
Private Sub Form_Load()
'Load all the image files from application path
strPath1 = App.Path & "\b1.jpg"
strPath2 = App.Path & "\b2.jpg"
strPath3 = App.Path & "\b3.jpg"
strPath4 = App.Path & "\b4.jpg"
'load the images
imgScr1.Picture = LoadPicture(strPath1)
imgScr2.Picture = LoadPicture(strPath2)
imgScr3.Picture = LoadPicture(strPath3)
imgScr4.Picture = LoadPicture(strPath4)
End Sub
Private Sub Timer1_Timer()
Static bytCounter As Byte
Select Case bytCounter
Case 0
imgScr1.Picture = LoadPicture(strPath4)
imgScr2.Picture = LoadPicture(strPath1)
imgScr3.Picture = LoadPicture(strPath2)
imgScr4.Picture = LoadPicture(strPath3)
bytCounter = 1
Case 1
imgScr1.Picture = LoadPicture(strPath3)
imgScr2.Picture = LoadPicture(strPath4)
imgScr3.Picture = LoadPicture(strPath1)
imgScr4.Picture = LoadPicture(strPath2)
bytCounter = 2
Case 2
imgScr1.Picture = LoadPicture(strPath2)
imgScr2.Picture = LoadPicture(strPath3)
imgScr3.Picture = LoadPicture(strPath4)
imgScr4.Picture = LoadPicture(strPath1)
bytCounter = 3
Case 3
imgScr1.Picture = LoadPicture(strPath1)
imgScr2.Picture = LoadPicture(strPath2)
imgScr3.Picture = LoadPicture(strPath3)
imgScr4.Picture = LoadPicture(strPath4)
bytCounter = 0
End Select
End SubProgram to find whether a matrix is symmetric or not
Option Explicit
Dim intMatrix(2, 2) As Integer
Private Sub Form_Activate()
'Variable Declaration
Dim intRow As Integer, intCol As Integer
Dim blnIsSymetric As Boolean
blnIsSymetric = True
'Take input in 3X3 Matrix
For intRow = 0 To 2
For intCol = 0 To 2
intMatrix(intRow, intCol) = InputBox("Enter the " _
& "Matrix element " & intRow & " " & intCol, "Enter element", "0")
Next intCol
Next intRow
'Evaluate the square of matrix
For intRow = 0 To 2
For intCol = 0 To 2
If intMatrix(intRow, intCol) intMatrix(intCol, intRow) Then
blnIsSymetric = False
Exit For
End If
Next intCol
Next intRow
'Print the matrix of form
For intRow = 0 To 2
Print: Print
For intCol = 0 To 2
Print intMatrix(intRow, intCol) & Space(10);
Next intCol
Next intRow
Print: Print
If blnIsSymetric = True Then
Print "Matrix is symetric"
Else
Print "Matrix is not symetric"
End If
End SubProgram To Make Digital Watch
Option Explicit
Private Sub Timer1_Timer() Label2.Caption = TimeEnd SubProgram To Make a Basic Calculator
Dim dblPrev As Double, dblNow As Double
Dim strOpt As String
Private Sub cmdAdd_Click()
dblPrev = Val(txtNum.Text)
strOpt = "+"
txtNum.Text = ""
End Sub
Private Sub cmdBS_Click()
txtNum.Text = Left(txtNum.Text, Len(txtNum.Text) - 1)
End Sub
Private Sub cmdClear_Click()
dblPrev = 0
dblNow = 0
txtNum.Text = ""
strOpt = "+"
End Sub
Private Sub cmdDigit_Click(Index As Integer)
txtNum.Text = txtNum.Text + cmdDigit(Index).Caption
End Sub
Private Sub cmdDivide_Click()
dblPrev = Val(txtNum.Text)
strOpt = "/"
txtNum.Text = ""
End Sub
Private Sub cmdEqual_Click()
dblNow = txtNum.Text
Select Case strOpt
Case "+"
txtNum.Text = dblPrev + dblNow
Case "-"
txtNum.Text = dblPrev - dblNow
Case "*"
txtNum.Text = dblPrev * dblNow
Case "/"
txtNum.Text = dblPrev / dblNow
Case Else
MsgBox "Invalid Operation"
End Select
dblPrev = dblNow
End Sub
Private Sub cmdMul_Click()
dblPrev = Val(txtNum.Text)
strOpt = "*"
txtNum.Text = ""
End Sub
Private Sub cmdSign_Click()
txtNum.Text = -(txtNum.Text)
End Sub
Private Sub cmdSqrt_Click()
txtNum.Text = Sqr(txtNum.Text)
End Sub
Private Sub cmdSub_Click()
dblPrev = Val(txtNum.Text)
strOpt = "-"
txtNum.Text = ""
End Sub