Sunteți pe pagina 1din 20

Q1. Design a simple structure of calculator? Ans.

At design time

At run time

Q2. Develop a greet application in VB that displays greeting text In a label & a image in a image box when show button is clicked & clear screen when clear button is clicked? Ans. At design time

Code window Private Sub Command1_Click() Image1.Picture = LoadPicture("C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\sunset.jpg") End Sub

Private Sub Command2_Click() Image1.Picture = LoadPicture("") End Sub

At run time

Q3. Develop an application in which data can be added to the list box from a text box when button is clicked? Ans. At design time

Code window Private Sub Command1_Click()

If Text1.Text <> " " Then List1.AddItem (Text1.Text) Text1.Text = " " Else MsgBox ("you have to write something in text box") End If

End Sub

At run time

Q4. Develop an application for security password checking?

Ans. At design time

Code window

Private Sub Command1_Click() End End Sub

Private Sub Command2_Click() If Text1.Text = "vishnu" Then MsgBox ("Password ok") Else MsgBox ("Worng Password, Try Again !!") End If Text1.Text = "" End Sub

At run time

Q5. Develop an application for restaurant billing system?

Ans. At design time

Code window

Private Sub cndcal_Click() Dim amt As Integer amt = 0 If chkpizza.Value = 1 Then amt = amt + 100 End If If chkveg.Value = 1 Then amt = amt + 200 End If If chkchomin.Value = 1 Then amt = amt + 300 End If If optcredit = True Then lblmsg = "mode of payment is credit" End If If optcash = True Then lblmsg = "mode of payment is cash" End If MsgBox ("your bill is rs" & amt) End Sub

Private Sub cmdend_Click() End End Sub

At run time

Q6. Design a form having command Menu bar file, edit, project

Submenu File new, open, save, save as Edit cut, copy, paste Project new, open, save project Ans. At design time

At run time

Q7. Design a form with menu having open, save commands. In which when user clicks the options in

submenu corresponding dialog boxes should be displayed to the user? Ans. At design time

Code window

Private Sub mnuopen_Click() CommonDialog1.FileName = "C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures" CommonDialog1.ShowOpen FileName = CommonDialog1.FileName End Sub

Private Sub mnusave_Click() CommonDialog1.ShowSave End Sub

At run time

option explicit dim as integer private sub command

state=1 shape1.backcolor=vbred shape2.backcolor=vbwhite shape3.backcolor=vbwhite label.caption="stop" end sub timer_time() if state=3 then state=1 else state=state+1 end if select case state case1 shape1.backcolor=vbred shape2.backcolor=vbwhite shape3.backcolor=vbwhite label.caption="stop" timer.interval=7000 case2 shape1.backcolor=vbwhite shape2.backcolor=vbgreen shape3.backcolor=white label.caption="wait" timer.interval=1000 case3 shape1.backcolor=vbwhite shape2.backcolor=vbwhite shape3.backcolor=vbgreen label.caption="go" timer.interval=1000 end select end sub

S-ar putea să vă placă și