Program to create toolbar contain the following tools. Notepad, Wordpad, Calculator, Windows Explorer, Paint Brush, MS Word, MS PowerPoint


Draw flowchart, write an algorithm and program in VB to create the toolbar.
Toolbar should contain the following tools.
Notepad, Wordpad, Calculator, Windows Explorer, Paint Brush, MS Word, MS PowerPoint, MS Excel.
User will click on any of the tools and related application should open.

Private Sub Toolbar1_ButtonClick(ByVal Button As

MSComctlLib.Button)
Select Case Button.Key
Case "a"
Shell "notepad"

Case "b"

Shell "C: \ Program
Files\WindowsNT\Accessories\Wordpad.exe"

Case "c"

Shell "C:\WINDOWS\system32\calc.exe"

Case "d"

Shell "explorer.exe"

Case "e"

Shell "C:\WINDOWS \system32\mspaint.exe"

Case "f"

Shell "C:\Program Files\Microsoft
office\Office10\Winword.exe"

Case"g"

Shell "C:\Program Filesl\Microsoft Office\Office10\powerpnt.exe"

Case"h"

Shell "C:\Program Filesl\Microsoft Office\Office10\excel.exe"

End Select


End Sub

Program to change fonts, font sizes in combo boxes and foreground, background color by using windows common control in Visual Basic


Draw flowchart, write an algorithm and program in visual basic to enter the string from the user. Display any four fonts, font sizes in combo boxes and foreground, background color by using windows common control. Give the option of bold, italic, underline and strike through in check boxes. User will select any font, size, color, font style and that should be applicable on the text box.

Private Sub chkBold_Click()

txtfont.FontBold = chkBold
End Sub

Private Sub chkItalic_Click()
txtfont.FontItalic = chkItalic
End Sub
Private Sub chkUnderline_Click ()

txtfont.FontUnderline = chkUnderline
End Sub
Private Sub chkstrike_Click()

txtfont.FontStrikethru = chkstrike
End Sub
Private Sub cboName_Click()

txtfont. FontName = cboName.Text
End Sub


Private Sub cboSize_Click()
txtfont. FontSize = cboSize.Text
End Sub
Private Sub cmdBcolor_Click()

cdBcolor. ShowColor
txtfont. BackColor = cdBcolor. Color
End Sub

Private Sub cmdFcolor_click()
cdFcolor.ShowColor

txtfont. ForeColor = cdFcolor .Color
End Sub

basic to select a company name, display the names in combo box.


Draw flowchart, write an algorithm and program in visual basic to select a company name, display the names in combo box.
Company Name: TVS, Hero Honda
After selecting the company name the list of corresponding vehicles Should be displayed in combo box.
Vehicle name: TVS-fiero, victor
: Hero Honda- Ambition,CBZ.
After selecting vehicle name the list of colors available and their rates should be displayed in combo box.
Colors: fiero- black, Red

: victor yellow , blue.
: Ambition black, silver.
: cbz Metallic & black
Price : fiero 50000 Rs.
Victor 45000 Rs.
Ambition 48000 Rs.
CBZ 52000 Rs.
Allow the user to select the bank. After selection the rate of interest should be displayed automatically
Bank: ICICI, HDFC

Rate of interest : ICICI: 9% HDFC: 9.4%
Allow the user to select the duration. Duration of installment 12,18,24 months.

Input down payment Calculate the balance amount , interest amount and EMI (equal months installments)


Dim dp As Integer
Dim emi, amt, roi As Single
Private Sub cboCompany_Click()
cboVehicle. Clear

If cboCompany.Text = "TVS" Then
cboVehicle.Addltem "Fiero" ,0
cboVehicle.Addltem "Vector", 1

Else
cboVehicle.Addltem "Ambition",0
cboVehicle.AddItem "CBZ", 1 End If

End Sub
Private Sub cboVehicle_Click()
cboColor. Clear

If cboVehicle. Text = "Fiero" Then
cboColor.AddItem "Black", 0

cboColor.AddItem "Red", 1
txtPrice.Text = "50000"
Elself cboVehicle.Text = "Victor" Then

cboColor.AddItem "Yellow", 0
cboColor.AddItem "Blue", 1
txtPrice.Text = "45000"
Elself cboVehicle.Text = "Ambition" Then

cboColor .Addltem "Black", 0
cboColor.Addltem "Silver", 1
txtPrice.Text = "48000"
Else: cboVehicle.Text = "Ambition"
cboColor.Addltem "Metallic", 0
cboColor.Addltem "Black", 1
txtPrice.Text = "52000"
End If

cboColor.Text = Clear
End Sub


Private Sub optHDFC_Click()
txtrate.Text = "9.4 %"

End Sub

Private Sub optICICI_Click()

txtrate.Text = "9 %"
End Sub


Private Sub

txtDPay_Validate (Cancel As Boolean)
dp = CInt(txtDPay.Text)

amt = CSng (txtPrice.Text) - dp
txtBalAmt.Text = CStr(amt)
If optICICI. Value = True Then
If opt12.Value = True Then

emi = ((amt * 9) / 100 + amt) / 12
Elself opt18.Value = True Then

emi = ((amt * 9) / 100 + (amt * 9) /100 / 2 + amt) / 18
Elself opt24.Value = True Then

emi = ((amt * 9) / 100 + (amt * 9) / 1000 * 2 + amt) / 24
End If

txtEMI. Text = emi
End If

If optHDFC.Value = True Then
If opt12.Value = True Then

emi = ((amt * 9.4) / 100 + amt) / 12
ElseIf opt18.Value = True Then

emi = ((amt * 9.4) / 100 + (amt * 9.4) / 100 / 2 + amt) 18
ElseIf opt24.Value = True Then
emi = ((amt * 9.4) / 100 + (amt * 9.4) / 1000 * 2 + amt) / 24
End If
txtEMI.Text = emi
End If
End Sub

create conditional report without data environment. Table must have fields students id,student name, parent name, address and date of admission.



Draw flowchart, write an algorithm and program in visual basic to create conditional report without data environment. Table must have fields students id,student name, parent name, address and date of admission. Input two dates of admission from the user and display the entire record between the two dates.

Ans:


Dim con As New ADODB.Connection

Dim stdrs As New ADODB. Recordset

Private Sub Command1_Click()

If stdrs.State = adStateOpen Then
stdrs.Close

End If

stdrs.Open "select * from studtable where date_admission >= #" & DTPicker1.Value & "# and date_admission <= #" & DTPicker2.Value & "#", con, adOpenDynamic, adLockBatchOptimistic


If (stdrs.BOF = True And stdrs.EOF = True) Then

MsgBox "Record Not Found........"
Else
Set DataReport1.DataSource = stdrs
DataReport1.Sections("Section1") .Controls (1) .DataField = stdrs.Fields(0) .Name
DataReport1.Sections("Section1") .Controls (2) .DataField = stdrs.Fields(1) .Name
DataReport1.Sections("Section1") .Controls (3) .DataField = stdrs.Fields(2) .Name
DataReport1.Sections("Section1") .Controls (4) .DataField = stdrs.Fields(3) .Name

'DataReport1.Sections("Section1") .Controls (5) .DataField = stdrs.Fields(4) .Name

'DataReport1.Sections("Section1") .Controls (4) .Caption = DTPicker2.Value
DataReport1.Show
End If


End Sub


Private Sub Command2_Click()

End
End Sub


Private Sub Form_Load()

If con. State = adStateOpen Then
con.Close
End If

con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E: \ASSINGMENT\bloodreport.mdb; Persist Security Info=False"

If stdrs.State = adStateOpen Then
stdrs.Close
End If


stdrs.Open "select * from studtable", con, adOpenDynamic, adLockBatchOptimistic
DTPicker1.Value = Now()
DTPicker2.Value = Now()


End Sub

create a conditional report. Table must have fields donor number, donor name,address,age,and blood group.



Draw flowchart, write an algorithm and program in visual basic to create a conditional report. Table must have fields donor number, donor name,address,age,and blood group. User will input the blood group name and the entire details having that blood group should be displayed.

Ans:


Dim con As New ADODB.Connection
Dim brs As New ADODB. Recordset
Private Sub Command1_Click()
If brs.State = adStateOpen Then

brs.Close
End If
brs.Open "select * from bloodgroupdetails where blood_group = '" &
Combo1.Text & "'", con, adOpenDynamic, adLockBatchOptimistic

If (brs.BOF = True And brs.EOF = True) Then
MsgBox "Record Not Found"

Else
Set DataReport2.DataSource = brs

DataReport2.Sections("Section1") .Controls (1) .DataField =

brs. Fields(0).Name
DataReport2. Sections("Section1") .Controls(2) .DataField =
brs. Fields (1) . Name
DataReport2. Sections("Section1") .Controls(3) .DataField =
brs. Fields(2) .Name
DataReport2.Sections("Section1") .Controls(4) .DataField =
brs. Fields(3). Name
DataReport2. Sections("Section1") .Controls(5) .DataField =
brs. Fields (4).Name
DataReport2.Show
End If
End Sub

Private Sub Command2_Click()

End
End Sub


Private Sub Form_Load()

If con.State = adStateOpen Then
con.Close
End If
con.Open "Provider = Microsoft.Jet.OLEDB.4.0;Data
Source=E:\ASSINGMENT\bloodreport.mdb;Persist Security Info=False"
If brs.State = adStateOpen Then
brs.Close
End If
If brs. State = adStateOpen Then
brs.Close
End If
brs.Open "select * from bloodgroupdetails", con, adOpenDynamic,
adLockBatchOptimistic
End Sub

create a popup menu having cut, copy and paste options.


Draw flowchart, write an algorithm and program in visual basic to create a popup menu having cut, copy and paste options. Apply these operations on the text in the text box.

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)


If Button = 2 Then

PopupMenu mnufile
End If
End Sub

Private Sub mnucopy_Click()

Clipboard.Clear
Clipboard.SetText txt1.SelText
End Sub

Private Sub mnucut_Click()

clipboard.SetText txt1.SelText
txt1.SelText = ""
End Sub

Private Sub mnupaste_Click()

txt1.SelText = Clipboard.GetText()
End Sub

Create the following menus. Math-AddSubstract, Multiply, Divide, Exit (Give separator before Exit)Trig-Sin, Cos, Tan.


Draw flowchart, write an algorithm and program in visual basic to Create the following menus. Math-AddSubstract, Multiply, Divide, Exit (Give separator before Exit)Trig-Sin, Cos, Tan.After users selects any of the menus corresponding program should work.
Note: Use MDI form.


Dim n1,n2, result As Integer

Dim n3, n4, res1 As Integer
Private Sub cmdClick1_Click()
nl = CInt(txtnum1.Text)
n2 = CInt (txtnum2.Text)

If MDIForm1.opr = "A" Then

frmCalculate.fraArith.Caption = "ADDITION"
result = n1 + n2 txtResult1.Text = result
End If

If MDIForm1.opr = "S" Then

frmCalculate.fraArith.Caption = "SUBTRACTION" result = n1 - n2
txtResult1.Text = result
End If

If MDIForm1.opr = "M" Then

frmCalculate.fraArith.Caption = "MULTIPLICATION"
result = n1 * n2
txtResult1. Text = result
End If

If MDIForm1.opr = "D" Then

frmCalculate.fraArith.Caption = "DIVISION"
result = n1/n2
txtResult1.Text = result
End If
End Sub
Private Sub Command2_Click()
Unload Me

MDIForm1.Show
End Sub

Private Sub cmdClick2_Click()

n4 = CDb1 (Text 4. Text)
n3 = CDb1 (n4)
If MDIForm1. opr = "ST" Then
A = (n3 * 180)/360
res1 = Sin (A)
txtResult2.Text = res1
End If

If MDIForm1.opr = "C" Then
frmCalculate.fraTrig.Caption = "COS OF ANGLE"
res1 = Cos (n3)
txtResult2.Text = res1

End If

If MDIForm1.opr = "T" Then

frmCalculate.fraTrig.Caption = "TAN OF ANGLE"
res1 = Tan(n3)
txtResult2.Text = res1
End If
End Sub

Private Sub Command4_Click()
Unload Me
MDIForm1.Show
End Sub

Private Sub Form_Resize()
Frame1.Left = (Me.Width - Frame1.Width)/ 2 - 50
Frame1.Top = (Me.Height - Frame1.Height)/ 2 - 230
End Sub

basic with a back and tool having fields employee number, employee name, marital status as to single or double


Draw flowchart, write an algorithm and program in visual basic to connect visual basic with a back and tool having fields employee number, employee name, marital status as to single or double (use option buttons). Give the privileges to add, save, delete, modify and search the record. Give all the navigation facility to the user.

Dim con As New ADODB.Connection

Dim rs As New ADODB.Recordset

Private Sub cmdClear_Click()

'Call clear1
'cmdSave.Enabled = True
'Text1.SetFocus

Text1.Text = " "
Text2.Text = " "
Option1. Value = False
0ption2.Value = False
Text1.SetFocus
End Sub

Private Sub cmdDelete_Click()

a = MsgBox("Are you sure?", vbYesNo, "CONFORMATION ALERT")
If a = vbYes Then
con.Execute "delete from employee where empcode=" &
Text1.Text
MsgBox " Record deleted ...."
If rs.State = adStateOpen Then
rs.Close
End If

rs.Open "select * from employee", con, adOpenDynamic,
adLockBatchOptimistic
rs.MoveFirst
Call show1
End If
End Sub


Private Sub cmdFisrt_Click()

If rs.State = adStateOpen Then
rs.Close
End If

rs.0pen "select * from employee",con, adOpenDynamic,
adLockBatchOptimistic
rs.MoveFirst
Call show1
End Sub

Private Sub cmdLast_Click()
If rs.State = adStateOpen Then

rs.Close
End If

rs.Open "select *from employee",con, adOpenDynamic

rs.MoveLast
Call show1
End Sub


Private Sub cmdModify_Click()

If Option1.Value = True Then
marstatus = "Single"
End If
If Option2.Value = True Then
marstatus = "Double"
End If
con.Execute "update employee set empname=" & Text2.Text &
" ', marstatus=' " & marstatus & " ' where empcode=" & " ' where empcode=" &
Text1.Text
MsgBox "Record Modified.....",vbOKOnly, "Update"
End Sub

Private Sub cmdNext_Click()

If rs.State = adStateOpen Then
rs.Close
End If
rs.Open "select * from employee", con,adOpenDynamic,
adLockBatchOptimistic
rs.MoveNext
If rs.EOF = True Then
rs.MoveLast
MsgBox "End of File encountered",vbOKOnly,"eof "
End If
Call show1
End Sub
Private Sub cmdPrevious_Click()
If rs. State = adStateOpen Then
rs.Close
End If
rs.Open "select * from employee",con, adOpenDynamic,
adLockBatchOptimistic
rs.MovePrevious
If rs.BOF = True Then
rs.MoveFirst
MsgBox "Begining Of File encounter..", vbOKOnly, "BOF"
End If
Call show1
End Sub
Private Sub cmdSave_Click()
If Option1. Value = True Then
marstatus = "Single"
End If

If Option2. Value = True Then
marstatus = "Double"
End If
con.Execute "insert into employee values(" & Text1.Text & ", ' " & Text2. Text &" ', ' " & marstatus & " ')"
MsgBox " Record saved....",vbOKOnly, "Save"
rs. Close

rs.Open
'cmdSave. Enabled = False
End Sub


Private Sub Command9_Click()
Unload Me
End Sub


Private Sub Form_Load()

con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=D:\adodb\connection.mdb;Persist Security Info=False"
If rs.State= adStateOpen Then
rs.Close
End If
rs.Open "select * from employee", con, adOpenDynamic,
adLockBatchOptimistic
If (rs.EOF= False And rs.BOF = False) Then
Call show1
'cmdSave. Enabled = False
End If
End Sub
Private Sub Form_Resize()
Frame1.Left = (Me.Width - Frame1.Width) / 2 - 50
Frame1.Top = (Me. Height - Frame1.Height) / 2 - 230
End Sub
Private Sub show1()
Text1.Text = rs! empcode
Text2.Text = rs! empname
If Trim (rs! marstatus) = "Single" Then
Option1.Value = True
Else
'If rs!marstatus = "Single" Then
Option2. Value = True
End If
End Sub

basic with a back end tool having fields roll number, name, address, marks, date of birth. Give the privileges to add,save,delete,modify and search


Draw flowchart, write an algorithm and program in visual basic with a back end tool having fields roll number, name, address, marks, date of birth. Give the privileges to add, save, delete, modify and search the records. Give all the navigation facilities to the user. Note: Use data control

Ans

Private Sub cmdAdd_Click()

add
Student. Recordset. AddNew
End Sub

Private Sub cmdFirst_Click()
Student. Recordset .MoveFirst
End Sub

Private Sub cmdLast_Click()
Student. Recordset .MoveLast
End Sub

Private Sub cmdNext_Click()
Student. Recordset.MoveNext
End Sub

Private Sub cmdPrevious_Click()
Student. Recordset.MovePrevious
End Sub

Private Sub cmdSave_Click()
save
Student. Recordset. Update
End Sub

Private Sub cmdModify_Click()
modify
Student. Recordset. Edit
End Sub

Private Sub cmdDelete_Click()
'delete

Student. Recordset. Delete
Student. Recordset. MoveFirst

End Sub

basic to Input an alphanumeric string and separate the characters and numbers.


Draw flowchart, write an algorithm and program in visual basic to Input an alphanumeric string and separate the characters and numbers.

Ans:


Dim str__len, I As Integer
Dim str, dig As String
Private Sub CmdSep_Click()
str = txtString.Text
str__len = Len(str)
For I = 1 To str_len

st = Mid(str,I, 1)
If Asc(st) >= 65 Or Asc(st) >= 112 Then
alpha = alpha + st
Elself Asc(st) >= 48 Or Asc(st) <= 57 Then

dig = dig + st
End If
Next

txtAlpha. Text = alpha
txtDigit.Text = dig
End Sub

basic to Perform multiplication of two matrices.


Draw flowchart, write an algorithm and program in visual basic to Perform multiplication of two matrices.

Dim m1(0 To 3) As Integer

Dim m2 (0 To 3) As Integer
Dim m3 (0 To 3) As Integer
Dim m4 (0 To 3) As Integer
Dim m5 (0 To 3) As Integer
Dim m6 (0 To 3) As Integer
Private Sub cmdEqual_Click()
For i = 0 To 3
m1(i) = CInt(txtm1(i).Text)
m2(i) = CInt (txtm2(i).Text)
Next
For j = 0 To 3
m3(j) = m1(0) * m2(j)
txtr1(j). Text = m3(j)
Next
For j = 0 To 3
m4(j) = m1(1) * m2(j)
txtr2(j) . Text = m4(j)
Next
For j = 0 To 3
m5(j) = m1(2) * m2(j)
txtr3(j).Text = m5(j)
Next
For j = 0 To 3
m6(j) = m1(3) * m2(j)
txtr4(j). Text = m6(j)
Next
End Sub

basic to Search an element from characters and as well as from numbers using binary search method.


Draw flowchart, write an algorithm and program in visual basic to Search an element from characters and as well as from numbers using binary search method.

Dim skey As Integer

Dim low, high, middle As Integer
Dim found As Boolean

Dim skey1 As String

Dim low1, high1, middlel As Integer
Dim found1 As Boolean
Private Sub cmdNumSearch_Click()
Binary search for Numbers
low = 0
high = 5
found = False
skey = CInt(txtSearch.Text)
Do While found <> True And low <= high
middle = (high + low) / 2

If txtArr (middle). Text < skey Then
low = middle + 1
Elself txtArr(middle).Text > skey Then

high = middle - 1
Else

found = True
End If
Loop
If found = True Then

MsgBox "Element found at:" + CStr(middle + 1)
Else

MsgBox " element not found"
End If
End Sub

Private Sub cmdCharSearch_LostFocus()
For I = 0 To 5

txtArr (I).Text = Clear
Next
End Sub

Private Sub cmdCharSearch_Click()
low1 = 0
high1 = 5
found1 = False
skey1 = txtSearch.Text

Do While found1 <> True And low1 <= high1
middle1 = (high1 + low1) / 2
If txtArr (middle1).Text < skey1 Then
low1 = middle1 + 1
Elself txtArr(middle1).Text > skey1 Then
high1 = middle1 - 1

Else
found1 = True
End If
Loop
If found1 = True Then

MsgBox "Element Found At :" + CStr(CInt(middle1 + 1))
Else

MsgBox "Element Not Found"
End If
End Sub

Private Sub cmdNumSearch_LostFocus()
For I = 0 To 5

txtArr(I).Text = Clear
Next
End Sub

To Search A Character From An Array Using Sequential Search


To Search A Character From An Array Using Sequential Search

Ans:


Dim SKEY As String
Dim FLAG As Boolean
Private Sub cmdSearch_Click()
SKEY = txtSearch. Text

For I = 0 To 5
If txtCArr(I).Text = SKEY Then
FLAG = True
Exit For
End If
Next

lblOutput1.Caption = Clear
If FLAG = True Then
lblOutput1.Caption = "The Element Is Found At " + CStr(I + 1) + " Position"
Else
lblOutput1. Caption = "ELEMENT NOT FOUND"
End If
End Sub
Private Sub cmdSearch_LostFocus()
For I = 0 To 5
txtCarr (I). Text = Clear
Next
End Sub

To Search A Number From An Array Using Sequential Search


To Search A Number From An Array Using Sequential Search

Ans:


Dim SKEY As String

Dim FLAG As Boolean
Private Sub cmdSearch_Click()
SKEY = CInt(txtSearch.Text)
FLAG = False
For I = 0 To 5
If txtNarr(I).Text = SKEY Then
FLAG = True
Exit For
End If
Next
If FLAG = True Then
IblOutput1.Caption = "The Element Is Found At Position" CStr (I + 1)

Else
IblOutput1. Caption = "Element Is Not Found"
End If
End Sub
Private Sub cmdSearch_LostFocus ()
For I = 0 To 5
txtNarr(I).Text = Clear
Next
End Sub

To Sort Characters with The Help of Bubble Sort


To Sort Characters with The Help of Bubble Sort

Ans :


Private sub cmdsort_LostFocus()

For I = 0 To 5
txtCarr(I)Text = Clear
Next
End Sub
Private Sub cmdSort_Click()
Dim I, J As Integer
Dim CArr (4) As String
For I = 0 To 4
CArr(I)= txtCarr(I).Text
Next

For I = 0 To 4
For J = 4 To I + 1 Step -1
If CArr (J) < CArr(J - 1) Then
X = CArr(J)
CArr (J) = CArr(J - 1)
CArr (J - 1) = X
End If
Next
Next
For I = 0 To 4
txtOutput(I).Text = CArr(I)
Next
End Sub

To sort Numbers with the help of Bubble Sort


To sort Numbers with the help of Bubble Sort

Private Sub cmdSort_Click()
Dim I,J,arr(5) As Integer
For I = 0 To 4

arr(I) = CInt(txtarr(I))
Next

Logic To Sort
J = 0

For I = 0 To 4
For J = 4 To I + 1 Step -1
If arr (J) < arr (J - 1) Then
X = arr(J)
arr(J) = arr(J - 1)
arr(J - 1) = X
End If
Next
Next
For I = 0 To 4

txtOutput(I).Text = CStr(arr(I))
Next
End Sub
Private Sub cmdSort_LostFocus()

For I = 0 To 5
txtarr(I).Text = Clear
Next

End Sub

To Sort Numbers Using Linear Sort


To Sort Numbers Using Linear Sort

Private Sub cmdSort_Click ()

Dim I, J, K, arr(4) As Integer
For I = 0 To 4

arr(I) = CInt(txtarr(I).Text)
Next
For I = 0 To 3

For J = I To 4
If arr(I) < arr(J) Then
X = arr(I)
arr(I) = arr(J)
arr(J) = X
End If
Next
Next
For I = 0 To 4

txtoutput (I) .Text = CStr (arr (I))
Next
End Sub

Private Sub cmdSort__LostFocus()
For I = 0 To 4

txtarr(I).Text = Clear
Next
End Sub

To Sort Characters Using Linear Sort


To Sort Characters Using Linear Sort

Private Sub cmdSort_Click()
0 To 3

Dim I, J, K As Integer
Dim arr(4) As String
For I = 0 To 4

arr(I) = txtarr(I).Text
Next
For I = For J = I To 4

If CStr(arr(I)) < CStr(arr(J)) Then
X = arr(I)
arr(I) = arr(J)
arr(J) = X
End If
Next
Next
For I = 0 To 4
txtOutput(I).Text = arr(I)
Next
End Sub

Private Sub cmdSort_LostFocus ()
For I = 0 To 4

txtarr(I).Text = Clear
Next
End Sub

basic to Conduct an online competitive exam.


Draw flowchart, write an algorithm and program in visual basic to Conduct an online competitive exam. The exam should contain any five questions. User will be given four choices as an answer. Give 10 marks for every correct answer and 0 for every wrong answer. Display summery of result at the end.

Q1 form

Public marks As Integer
Public f1, f2, f3, f4, f5 As Boolean
Private Sub cmdNext_Click()
If opt Float.Value = True Then

marks = merks + 10
f1 = True
Else
marks = marks + 0
f1 = False
End If
frmQ2 .Show
End Sub

Q2 Form

Private Sub Command1_Click()
If optDev.Value = True Then
frmQl.marks = frmQl.marks + 10
frmQl.f2 = True
Else

frmQl.marks = frmQl.marks + 0
frmQl.f2 = False
End If
frmQ3.Show
End Sub


Q3 Form

Private Sub cmdNext_Click()
If optFoxPro. Value = True Then
frmQ1. marks = frmQl.marks + 10
frmQl.f3 = True
Else

frmQ1. marks = frmQl.marks + 0
frmQ1.f3 = False
End If

frmQ4.Show
End Sub

Q4 Form

Private Sub cmdNext_Click()
If optVbgreen. Value = True Then
frmQ1.marks = frmQ1.marks + 10
frmQ1.f4 = True
Else
frmQ1. marks = frmQl. marks + 0
frmQ1.f4 = False
End If

frmQ5.Show
End Sub


Q5 Form

Private Sub cmdNext_Click()
If opt False. Value = True Then
frmQ1.marks = frmQ1.marks + 10
frmQ1.f5 = True

Else
frmQ1. marks = frmQ1.marks + 0
frmQ1.f5 = False
End If

frmResult.Show
End Sub


Result Form

Private Sub cmdTotal_Click().
If frmQ1. f1 = True Then
txtQ1.Text = "Correct"
Else

txtQ1.Text = "Wrong"
End If
If frmQl.f2 = True Then

txtQ2.Text = "Correct"
Else

txtQ2.Text = "Wrong"
End If

If frmQl.f3 = True Then
txtQ3.Text = "Correct"

Else
txtQ3.Text = "Wrong"
End If
If frmQl.f4 = True Then

txtQ4.Text = "Correct"
Else

txtQ4.Text = "Wrong"
End If
If frmQl.f5 = True Then

txtQ5.Text = "Correct"
Else

txtQ5.text = "Wrong"
txtMarkS.Text = frmQl.marks
End Sub
Private Sub cmdExit_Click()
End
End Sub

basic to input consumer number, consumer name,area urban,ruraly,month of billing,last reading,current reading andcalculate thebill amount


Draw flowchart, write an algorithm and programin visual basic to input consumer number, consumer name, area (urban,ruraly, month of billing, last reading, current reading and calculate the bill amount according to the following conditions.
Household:
1 to 30 - 1.00Rs.
31 to 100 - 2.55Rs.
101 to 300 - 2.95Rs.
301 onwards - 4.55Rs.
Industrial:
1 to 1000 - 2.40Rs.
1001 to 1500 - 3.00Rs.
1501 onwards - 3.40Rs.
Non Household:
1 to 100 - 2.56RS.
101 to 200 - 4.10Rs.
201 onwards - 5.00Rs.
Urban water supply - 2.25 Rs.
Rural, water supply - 1.40 Rs .
Agriculture - 0.90Rs.
Rural Lighting - 1.70Rs.
Urban Lighting - 2.50Rs.
Poultry Farm - 0.90Rs.
Total Reading = Current Reading - Last Reading

Ans:


Dim c, r1, a, b, p As Integer


Private Sub Form_Load()

cboOptions.Addltem "HOUSEHOLD", 0
cboOptions. Addltem "NONHOUSEHOLD",1
cboOptions.Addltem " IDNUSTRIAL", 2
cboOptions.Addltem "URBAN WTAER SUPPLY", 3
cboOptions. Addltem "RURAL WATER SUPPLY", 4
cboOptions.Addltem "AGRICULTURE", 5
cboOptions.Addltem "RURAL LIGHTING", 6
cboOptions.Addltem "URBAN LIGHTING", 7
cboOptions.Addltem "POULTRY FARM", 8

End Sub


Private Sub cmdCalculate_Click ()
p2 = 0

t1 = cboOptions.Text
c = Clnt(txtCMR.Text) - CInt (txtLMR. Text)
If t1 = "HOUSEHOLD" Then for Household purpose
If c > 300 Then
r1 = c - 300
p = rl * 4.55
p2 = p + 798.5

End If


If c > 100 And c <= 300 Then
r1 = c - 100
p = r1 * 2.95
p2 = p + 208.5

End If
If c > 30 And c <= 100 Then
r1 = c - 30
p = r1 * 2.55
p2 = p + 30

End If
If c <= 30 Then
r1 = c - 0
p = r1 * 1
p2 = p

End If
Elself t1 = "NONHOUSEHOLD" Then for non household
If c > 200 Then

r1 = c - 200
p= r1 * 5
p2 = p + 660
End If
If c > 100 And c <= 200 Then
r1 = c - 100
p = r1 * 4.1
p2 = p + 250
End If
If c <= 100 Then
r1 = c - 0
p = r1 * 2.5
p2 = p
End If
Elself t1 = "IDNUSTRIAL" Then for Industrial
If c > 15000 Then

r1 = c - 15000
p = r1 * 3.4

p2 = p + 44400
End If
If c > 1000 And c <= 15000 Then

r1 = c - 1000
p = r1 * 3
p2 = p + 2400
End If
If c <= 1000 Then

r1 = c - 0
p = r1 * 2.4
p2 = p
End If
Elself t1 = "URBAN WTABR SUPPLY" Then
p2 = c * 2.25
Elself t1 = "RURAL WATER SUPPLY" Then
p2 = c * 1.4

Elself t1 = "AGRICULTURE" Then
p2 = c * 0.9
Elself t1 = "RURAL LIGHTING" Then

p2 = c * 1.7
Elself t1 = "URBAN LIGHTING" Then

p2 = c * 2.5
Else
p2 = c * 0.9
End If

txtTAmt.Text = CStr(p2)

End Sub

Private Sub cmdClear_Click()
txtName.Text = Clear
txtNumber.Text = Clear

txtMOB.Text = Clear
txtLMR.Text = Clear
txtCMR.Text = Clear
cboOptions. Text = Clear

End Sub
Private Sub cmdExit_Click()
Unload Me

End Sub

basic to Input telephone number, consumer name, address, area (rural urban),Number of calls.


Draw flowchart, write an algorithm and program in visual basic to Input telephone number, consumer name, address, area (rural urban),Number of calls. Calculate the telephone bill by using following conditions: Urban
a) Rental 250
b) Free calls 150
c) 151 to 400 calls - 0.80 Rs.
d) 401 to 1000 calls - 1 Rs.
e) 1001 onwards - 1.20Rs.
Rural
a) Rental 180
b) Free calls 250
c) 251 to 450 calls - 0.60 Rs.
d) 451 to 500 calls - 0.80RS.
e) 501 to 1000 - lRs.
f) 1001 onwards - 1.20 Rs.

Ans :


Dim Ncall As Integer Private Sub Form Load ()

optRural.Enabled = False
optUrban.Enabled = False

End Sub


Private Sub optRural_Click()

Ncall = CInt(txtCalls.Text)
If Ncall <= 180 Then s = 180 Elself Ncall >= 251 And Ncall <= 450 Then s = Ncall * 0.6 * 180 Elself Ncall >= 451 And Ncall <= 500 Then s = Ncall * 0.8 * 180 Elself Ncall > 501 And Ncall <= 1000 Then s = Ncall * 1 * 180 Elself Ncall > 1000 Then s = Ncall * 1.2 * 180

End If

txtFcall.Text = 250 txtTamt.Text = s

End Sub

Private Sub optUrban_Click()
Ncall = 0


If Ncall <=150 Then s = 250 Elself Ncall >= 151 And Ncall <= 400 Then s = Ncall * 0.8 * 250 Elself Ncall >= 401 And Ncall <= 1000 Then s = Ncall * 1 * 250 Elself Ncall > 1000 Then S = Ncall * 1.2 * 250

End If

txtFcall.Text = 150 txtTamt. Text = s

End Sub

Private Sub txtCalls_LostFocus() optRural. Enabled = True
optUrban.Enabled = True

End Sub

basic to Arrange the given pairs of options and allow the user to match the pairs.


Draw flowchart, write an algorithm and program in visual basic to Arrange the given pairs of options and allow the user to match the pairs. If user has selected the correct option then the result should be given by displaying green color, red color otherwise. Correct pairs are given below:
Sachin Tendulkar : Cricket V.Anand : Chess
Leander Pace : Tennis
Mike Tyson : Boxing -
Note: Use option buttons.

Ans :


Private Sub optChess_Click()

If optAnand.Value = True Then txtcolor.BackColor = vbGreen

Else

txtcolor.BackColor = vbRed

End If

End Sub
Private Sub optTennis_Click()

If optPace. Value = True Then
txtcolor.BackColor = vbGreen

Else

txtcolor.BackColor = vbRed

End If

End Sub

Private Sub optCricket_Click ()
If optSachin.Value = True Then
txtcolor.BackColor =

vbGreen

Else

txtcolor.BackColor = vbRed

End If


End Sub

Private Sub optBoxing_Click()
If optTyson.Value = True Then
txtcolor.BackColor = vbGreen
Else
txtcolor.BackColor = vbRed

End If
End Sub

basic to Enter a date of birth from the user and calculate his age in days, months and years as on current date.


Draw flowchart, write an algorithm and program in visual basic to Enter a date of birth from the user and calculate his age in days, months and years as on current date. Current date should be taken from the system.
Note: Use DTpicker control.

Ans:


Dim dob, curdate As Date

Dim d1, m1, y2, d2, m2, y1, d3, m3, y3 As Integer
Private Sub cmdAge_Click ()
dob = CDate(txtDob. Text) curdate = CDate(txtCDate.Text) d1 = Day(dob) m1 = Month (dob) y1 = Year (dob) d2 = Day(curdate)
y2 = Year(curdate)
If d1 > d2 Then d2 = d2 + 30 m2 = m2 - 1 End If
If m1 > m2 Then
m2 = m2 + 12 y2 = y2 - 1

End If


m3 = m2 - m1 Y3 = Y2 - Y1 d3 = d2 - d1 txtDay. Text = d3 txtMonth.Text = m3 txtYear. Text = y3 End Sub
Private Sub txtCDate_GotFocus ()
txtCDate. Text = Date

End Sub


Private Sub txtDob_Vali date (Cancel As Boolean)
If IsDate(txtDob.Text) = False Then MsgBox "Enter The Valid date" txtDob. Text = Clear txtDob.SetFocus

End If

End Sub

basic to Generate a stopwatch for 10 minutes. Note: Use timer control.


Draw flowchart, write an algorithm and program in visual basic to Generate a stopwatch for 10 minutes. Note: Use timer control.

Ans:


Dim sec, min As Integer

Private Sub Timer1_Timer () sec = sec + 1 If sec = 60 Then sec = 0 min = min + 1
If min = 10 Then
MsgBox "10 minutes over" Timer1.Enabled = False

End If

End If

End Sub

basic to enter a decimal number from the user and convert it into equivalent binary number.


Draw flowchart, write and algorithm and program in visual basic to enter a decimal number from the user and convert it into equivalent binary number.
From should be designed in such a way that all the controls should be located centrally in every size of the form.

Ans


Dim t As Integer

Dim d, num, sum As Single
Private Sub cmdClear_Click()
txtBinary. Text = Clear txtValue .Text = Clear

End Sub

'Logic To Convert Decimal To Binary Private Sub cmdConvert_Click()
t = 1
sum =0
num = CInt(txtValue.Text)
n = num
While Not num = 0 d = num Mod 2 sum = sum + (d * t)
t = t * 10
num = num \ 2
Wend
txtBinary.Text = CStr(sum)
End Sub

basic to Input at least four digit number from the user and print the addition of all the digit of given number.


Draw flowchart, write an algorithm and program in visual basic to Input at least four digit number from the user and print the addition of all the digit of given number.
From should be designed in such a way that all the controls should be located centrally in every size of the form.

Ans:


Dim r, I, num, sum As Integer Dim rev As String

Private Sub cmdReverse_Click() sum = 0 num = CInt(txtnumber.Text)
For I =0 To 4
r = num Mod 10 num = num / 10
rev = rev + Str(r)
sum = sum + r
Next txtReverse.Text = rev
txtSum.Text = sum
End Sub

Visual Basic-6 has emerged as one of the standard Windows Programming Language and it has become a must for all Software people for developing Applications in Visual Environment. So it is, one must learn Visual Basic-6.

What is our Objective in this Courseware?


The Overall Objective in this Courseware is to give a Hands-on Approach to develop different projects in Visual Basic-6.0 using intrinsic, professional and user–created ActiveX controls and also develop projects using databases, DAO’s, ADO’s, DLL’s, Documents, Crystal Reports etc. covering almost all the essential features of VB-6 Professional Edition. After reading one lesson any interested reader will be able to get complete hands-on experience with the VB project and get a sense of fulfilment and achievement. Learning by doing is the motto with which this courseware is written. After giving a short introduction about VB-6 we will explain how to create and execute a project in VB using some intrinsic ActiveX controls. Creating and executing projects will be the central theme of all the lessons which we will be giving in this courseware.

What is Visual Basic-6?


Visual Basic-6 has its origin in Basic which was developed round about the year 1960, when high level languages were just being introduced to the computer community. Microsoft has made it extremely powerful by gearing all its good features to the Windows environment. Starting with the version 3 and then with 4, and then with 6, Visual Basic is now at version 6. Basic is a Procedure Oriented Language intended to implement single tasks in text based environment whereas Visual Basic is an Event Driven Language intended to implement Projects or Applications containing multiple tasks in Windows Environment.

What can Visual Basic do for you?

Visual Basic can serve as an ideal front end tool for the clients to interact. It has got connectivity mechanisms for all types of databases situated far and wide in a network and so it can cater to the needs of a large body of clients. Using the latest ActiveX technologies, it can integrate the functionalities provided by other applications like Word Excel and other Windows. Its internet capabilities provide easy access to documents and applications across the internet. Above all it embodies the Object Oriented Technology, which is the cutting edge technology for all the present day developments in the Software World. The final application is a true EXE file and so can be freely distributed.


Structure of VB-6 Projects:


We said earlier that VB-6 implements projects or applications. A project is developed using one or more Forms. A Form is simply a window containing one or more Controls. Controls in VB consist of labels, text boxes, list boxes, combo boxes, scroll bars etc. which are the constituents of windows environment. It is only the controls that give VB, its immense power and so there is a lot of interest in creating more and more powerful controls. ActiveX controls mark a significant development in controls technology. In fact all controls in VB-6 are ActiveX controls, which have the extension .ocx. These controls have properties whose values can be initialized at design time and also varied during run time. The properties are something like variables. The controls are activated by codes written in a high level language. By associating our problem variables with the properties of the controls, our problem variables can be manipulated to give the problem solution. In summary we can say that a VB project is made of forms, controls and their properties and codes.

Integrated Development Environment:

The working environment in VB is often referred to as the Integrated Development Environment or IDE, because it integrates many different functions such as design, editing, compiling and debugging within a common environment. Since all our projects are developed only in the IDE, let us now have a brief look at its features. You will be able to understand their uses at the time of building projects. The VB IDE looks as shown in the figure.