Bca 5th Sem
Bca 5th Sem
Bca 5th Sem
Option Explicit
Private Sub Form_Load()
'Variable declaration
Dim intNum As Integer, intFactSum As Integer, intCounter As Integer
For intNum = 1 To 1000
'Calculate the sum of the factors of intTemp
intFactSum = 0
For intCounter = 1 To intNum - 1
If (intNum Mod intCounter) = 0 Then
intFactSum = intFactSum + intCounter
End If
Next intCounter
If intNum = intFactSum Then
lstOutput.AddItem (Str(intNum))
End If
Next intNum
End Sub
Option Explicit
Private Sub cmdOk_Click()
'Variable Declaration
Dim strInput As String, strTemp As String
Dim intTotChar As Integer, intLength As Integer
'Fetch the string from text box (txtInput) into strInput
strInput = txtInput.Text
'Get the length of string
intLength = Len(strInput)
'Clear the form contents if any
Form1.Cls
For intTotChar = 1 To intLength
strTemp = Left(strInput, intTotChar)
Form1.Print strTemp
Next intTotChar
For intTotChar = intLength - 1 To 1 Step -1
strTemp = Left(strInput, intTotChar)
Form1.Print strTemp
Next intTotChar
End Sub
Option Explicit
Dim strMyusername As String, strMyPassword As String
Private Sub cmdLogin_Click()
'Variable declaration
Dim strUserName As String, strPassword As String
Dim intResponse As Integer
Static intAttempt As Integer
'Check if user attempted 3 times then exit the application
If intAttempt = 2 Then
MsgBox "You have made 3 wrong attempt" _
& "so now application will have to close immediately"
End
End If
'Fetch the username and password in from txtUserName and txtPassword respectively
strUserName = txtUserName.Text
strPassword = txtPassword.Text
'check wheather given username and password is match or not
If strUserName = strMyusername And strPassword = strMyPassword Then
MsgBox "Welcome to your account", , "Welcome"
End
Else
intAttempt = intAttempt + 1
intResponse = MsgBox("Invalid username or password" & vbCrLf _
& "Would you like to retry ?", vbRetryCancel, "Login Error")
If intResponse = vbRetry Then
txtUserName.SetFocus
Else
End
End If
End If
End Sub
Private Sub Form_Load()
'Set the username and password
strMyusername = "Brajmohan"
strMyPassword = "Gamer"
End Sub
Private Sub txtPassword_GotFocus()
txtPassword.SelStart = 0
txtPassword.SelLength = Len(txtPassword.Text)
End Sub
Private Sub txtUserName_GotFocus()
txtUserName.SelStart = 0
txtUserName.SelLength = Len(txtUserName.Text)
End Sub
End Sub
Private Sub cmdFirst_Click()
'Move to the first record
Data1.Recordset.MoveFirst
End Sub
Private Sub cmdLast_Click()
'Move to the last Record
Data1.Recordset.MoveLast
End Sub
Private Sub cmdModify_Click()
'Unlock all the text boxes on form
For Each ctrl In Form1.Controls
If TypeOf ctrl Is TextBox Then
ctrl.Locked = False
End If
Next
Data1.Recordset.Edit
End Sub
Private Sub cmdNext_Click()
'Move to the next record
Data1.Recordset.MoveNext
'Check if end of file then move to the last record
If Data1.Recordset.EOF Then
Data1.Recordset.MoveLast
End If
End Sub
Private Sub cmdPrevious_Click()
'Move to the previous record
Data1.Recordset.MovePrevious
'Check if begining of file then move to the first record
If Data1.Recordset.BOF Then
Data1.Recordset.MoveFirst
End If
End Sub
Private Sub cmdRem_Click()
'Delete the current record
Data1.Recordset.Delete
Data1.Recordset.MoveNext
'Check if end of file then move to the last record
If Data1.Recordset.EOF Then
Data1.Recordset.MoveLast
End If
End Sub
Private Sub cmdSearch_Click()
Dim intRoll As Integer
'Ask for the roll number of student
intRoll = Val(InputBox("Enter the roll number of student do you want to search", "Roll number",
"0"))
'Move to the first record
Data1.Recordset.MoveFirst
'Loop through all the records of database
Do While Data1.Recordset.EOF = False
'Check if desired record is found then exit loop
If Data1.Recordset.Fields("rollno") = intRoll Then
Exit Do
End If
Data1.Recordset.MoveNext
Loop
'if end of file then record is not found and move to the last record
If Data1.Recordset.EOF Then
MsgBox "Cannot find the specified record ", vbInformation, "No such record"
Data1.Recordset.MoveLast
End If
End Sub
Private Sub cmdUpdate_Click()
'Update the record and lock all the text boxes of form
Data1.Recordset.Update
For Each ctrl In Form1.Controls
If TypeOf ctrl Is TextBox Then
ctrl.Locked = True
End If
Next ctrl
End Sub
Private Sub Form_Load()
'Connect to the database and bound all textboxes to that data control(data1)
Data1.DatabaseName = App.Path & "\student.mdb"
Data1.RecordSource = "student"
Option Explicit
Private Sub cmdOk_Click()
'Variable Declaration
Dim intFirstNo As Integer, intSecondNo As Integer, intSumFact1 As Integer
Dim intSumFact2 As Integer, intCounter As Integer
'Fetch the numbers from textboxes (txtFirstDig,txtSecNo)
intFirstNo = Val(txtFirstDig.Text)
intSecondNo = Val(txtSecDig.Text)
'Obtain the sum of factors of first number
For intCounter = 1 To intFirstNo - 1
If (intFirstNo Mod intCounter) = 0 Then
intSumFact1 = intSumFact1 + intCounter
End If
Next intCounter
'Obtain the sum of factors of second number
For intCounter = 1 To intSecondNo - 1
If (intSecondNo Mod intCounter) = 0 Then
intSumFact2 = intSumFact2 + intCounter
End If
Next intCounter
'Check if both sum of factors are equal to each other then numbers are amicable
If intSumFact1 = intSecondNo And intSumFact2 = intFirstNo Then
Label3.Caption = "Numbers are amicable"
Else
Label3.Caption = "Numbers are not amicable"
End If
End Sub
Option Explicit
Private Sub cmdOk_Click()
'Variable Declaration
Dim intVowel As Integer, intWord As Integer
Dim intDigit As Integer, intSpace As Integer
Dim intSpChar As Integer
Dim strTemp As String, strInput As String
Dim intCounter As Integer, intAsc As Integer
Dim blnNextChar As Boolean
'Fetch the string from text box(txtInput) into strInput
strInput = txtInput.Text
blnNextChar = True
'Parse the string
For intCounter = 1 To Len(strInput)
strTemp = Mid(strInput, intCounter, 1)
intAsc = Asc(UCase(strTemp))
If strTemp = " " Then
intSpace = intSpace + 1
blnNextChar = True
Else
intAsc = Asc(UCase(strTemp))
If blnNextChar Then
intWord = intWord + 1
blnNextChar = False
End If
Select Case intAsc
Case 48 To 58
intDigit = intDigit + 1
Case 65 To 91
Select Case UCase(strTemp)
Case "A"
intVowel = intVowel + 1
Case "E"
intVowel = intVowel + 1
Case "O"
intVowel = intVowel + 1
Case "U"
intVowel = intVowel + 1
Case "I"
intVowel = intVowel + 1
End Select
Case Else
intSpChar = intSpChar + 1
End Select
End If
Next intCounter
'Print the output
lblVowel.Caption = "Total Vowels : " & intVowel
lblSpChar.Caption = "Total special characters : " & intSpChar
lblSpace.Caption = "Total Spaces : " & intSpace
lblWord.Caption = "Total Words : " & intWord
lblDigit.Caption = "Total Digits : " & intDigit
End Sub
Option Explicit
Private Sub cmdOk_Click()
'Variable Declaration
Dim intcounter As Integer
Dim strInput As String
'Fetch the string from textbox(txtinput) into strInput
strInput = txtInput.Text
'Clear the list contents if any
lstOutput.Clear
For intcounter = 1 To Len(strInput)
'Add the given string to list box(lstOutput)
lstOutput.AddItem (strInput)
Next intcounter
End Sub
Option Explicit
Private Sub cmdReverse_Click()
'Variable Declaration
Dim lngInput As Long
Dim lngOutput As Long
'Fetch the number from textbox(txtInput) into lngInput
lngInput = Val(txtInput.Text)
'Call the function Reverse for reverse the inputed number and
'Store the reversed number into lngOutput
lngOutput = Reverse(lngInput)
'Print the Reverse number
lblOutput.Caption = "The Reverse Number is " & Str(lngOutput)
End Sub
'User Defined Function to reverse the give number
Public Function Reverse(ByVal lngTemp As Long) As Long
Dim intRem As Integer
Dim lngResult As Long
While lngTemp > 0
intRem = lngTemp Mod 10
lngResult = (lngResult * 10) + intRem
lngTemp = lngTemp / 10
Wend
Reverse = lngResult
End Function
Option Explicit
Private Sub Form_Activate()
'Variable Declaration
Dim intArray(2, 2) As Integer
Dim intRow As Integer, intCol As Integer
Dim intTemp As Integer, intNext As Integer
'Take input from user into matrix
For intRow = 0 To 2
For intCol = 0 To 2
intArray(intRow, intCol) = Val(InputBox("Enter the Element" _
& intRow & "Row " & intCol & "Col", "Enter Matrix", "0"))
Next intCol
Next intRow
Print "Matrix Before Sorting : ": Print: Print
For intRow = 0 To 2
For intCol = 0 To 2
Print Space(8) & intArray(intRow, intCol);
Next intCol
Print: Print
Next intRow
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
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
Option Explicit
Private Sub Timer1_Timer()
Label2.Caption = Time
End Sub