Você está na página 1de 15

VISUAL PROGRAM LIST:

Part -B Programs

11. Write a VB program to design a simple calculator to perform addition,


subtraction, multiplication and division (control Arrays)

12. Create a VB Application to change the color of the text in a text box use scroll
bar for the selection of colors

13. Write a VB Application to demonstrate parameter passing

14.VB Application to write into a Binary File and To Read from a binary File

15.Write a VB program to Encrypt and Decrypt a string.

16.Write a VB program to Load an image using Drive list box, file list box and
directory list box.

17.Design a VB application to demonstrate Manipulation(add, save, update,


delete) and Navigation of Records using recordset methods

18.Write a VB program to show SCROLLBAR


19.Write a VB program to show SCREEN SAVER
20.Design a VB program to show SPLASH SCREEN

Part A 7. User Authentication


Private Sub cmdOK_Click()
Adodc1.Refresh
Do Until Adodc1.Recordset.EOF
If Adodc1.Recordset.Fields("field1").Value = txtUserName And
Adodc1.Recordset.Fields("field2").Value = txtPassword Then
Me.Hide
Form1.Show
Exit Sub
Else
Adodc1.Recordset.MoveNext
End If
Loop
txtUserName = ""
txtPassword = ""
x = MsgBox("Invalid password, try again!")
End Sub

Part A 8. Book Search

Private Sub cmdexit_Click()

End
End Sub

Private Sub cmdsearch_Click()

If cmbsearchby.Text = "isbn" Then

Adodc1.RecordSource = "select * from booktable where isbn= " & Val(txtsearchstring.Text)

ElseIf cmbsearchby.Text = "title" Then

Adodc1.RecordSource = "select * from booktable where title ='" & txtsearchstring.Text & "'"

ElseIf cmbsearchby.Text = "author" Then

Adodc1.RecordSource = "select * from booktable where author='" & txtsearchstring.Text & "'"

Else

Adodc1.RecordSource = "select * from booktable"

End If

Set DataGrid1.DataSource = Adodc1

DataGrid1.Refresh

Adodc1.Refresh

End Sub
Part-B
13. Write a VB Application to demonstrate parameter passing
Private Sub Cmdbyvalue_Click()

Dim value As Single

value = Val(Text1.Text)

Call example1(value) 'call by value

Text2.Text = value

MsgBox "Displaying call by value"

End Sub

Sub example1(ByVal test As Single)

test = 20

End Sub

Sub example2(ByRef test As Single)

test = 20

End Sub

Private Sub Cmdbyref_Click()

Dim value As Single

value = Val(Text1.Text)

Call example2(value) 'call by Reference

Text2.Text = value

MsgBox "Displaying call by Reference"

End Sub
Part-B
15. Write a VB program to Encrypt and Decrypt a string.
Private Sub Command1_Click()

Text2.Text = Encrypt(Text1.Text, Len(Text1.Text))

End Sub

Encryption & Decryption

Public Function Encrypt(Name As String, Key As Long) As String

Dim v As Long, c1 As String, z As String

For v = 1 To Len(Name)

c1 = Asc(Mid(Name, v, 1))

c1 = Chr(c1 + Key)

z = z & c1

Next v

Encrypt = z

End Function

Private Sub Command2_Click()

Text2.Text = Decrypt(Text2.Text, Len(Text1.Text))

End Sub

Encryption & Decryption

Public Function Decrypt(Name As String, Key As Long) As String

Dim v As Long, c1 As String, z As String

For v = 1 To Len(Name)

c1 = Asc(Mid(Name, v, 1))

c1 = Chr(c1 - Key)
z = z & c1

Next v

Decrypt = z

End Function

Part-B
16. Write a VB program to Load an image using Drive list box, file
list box and directory list box.

Private Sub Command1_Click()

End

End Sub

Private Sub Dir1_Change()

File1.Path = Dir1.Path

End Sub

Private Sub Drive1_Change()

Dir1.Path = Drive1.Drive

End Sub

Private Sub File1_Click()

Image1.Picture = LoadPicture(File1.Path & "\" & File1.filename)

End Sub

Private Sub Form_Load()

File1.Pattern = "*.jpg;*.bmp;*.gif"

End Sub
Part- B

17. Design a VB application to demonstrate Manipulation (add, save, update,


delete) and Navigation of Records using recordset methods
Code for adding a record

Private Sub cmdadd_Click()

Dim id As Integer

On Error GoTo errmsg

Adodc1.Refresh

Adodc1.Recordset.MoveLast

id = Adodc1.Recordset("ROLL_NO") + 1

Adodc1.Recordset.AddNew

Text1.Text = id

Text2.SetFocus

Exit Sub

errmsg:

Adodc1.Recordset.AddNew

Text1.Text = 1

Text2.SetFocus

End Sub

Code for saving a record

Private Sub cmdsave_Click()

On Error GoTo errmsg

Adodc1.Recordset.Update

MsgBox " Record saved"

Exit Sub

errmsg:
MsgBox "Duplicate Item id"

Adodc1.Recordset.CancelUpdate

End Sub

Code for updating a record

Private Sub cmdupdate_Click()

Text1.Enabled = False

student_Name = Text2.Text

Adodc1.Recordset.Update

End Sub

Code for Deleting a record

Private Sub cmddelete_Click()

On Error GoTo errmsg

Adodc1.Recordset.Delete

Adodc1.Recordset.MoveNext

MsgBox "items deleted successfully"

Text1.Text = ""

Text2.Text = ""

Exit Sub

errmsg:

MsgBox "error"

End Sub

Code for navigation of first record

Private Sub cmdmovefirst_Click()

On Error GoTo errmsg

Adodc1.Recordset.MoveFirst

Exit Sub
errmsg:

MsgBox "Item list is empty"

End Sub

Code for navigation of next record

Private Sub cmdmovenext_Click()

Adodc1.Recordset.MoveNext

If Adodc1.Recordset.EOF Then

MsgBox " you r viewing last record"

End If

End Sub

Code for navigation of previous record

Private Sub cmdmoveprevious_Click()

If Adodc1.Recordset.BOF Then

MsgBox " you r viewing First record"

End If

Adodc1.Recordset.MovePrevious

End Sub

Code for navigation of last record

Private Sub cmdmovelast_Click()

On Error GoTo errmsg

Adodc1.Recordset.MoveLast

Exit Sub

errmsg:
MsgBox "Item list is empty"

End Sub

Private Sub cmdrefresh_Click()

Adodc1.Refresh

End Sub

Você também pode gostar