Professional Documents
Culture Documents
Student Name:
VISUAL
PROGRAMMING LAB
MANUAL
Program List:
Part -B Programs
12. VB Application to change the color of the text in a text box use scroll bar for the selection of
colors
14.VB Application to write into a Binary File and To Read from a binary File
15. VB program to Encrypt and Decrypt a string.(Use Rnd() to generate the Encryption and
Decryption keys.)
16. Write a VB program to Animate an Image
17.VB program to validate Fractional Number
18.VB program to show SCROLLBAR
19.VB program to show SCREEN SAVER
20.VB program to show SPLASH SCREEN
End Sub
Part A 2. MDI Form
Option Explicit
Dim dbcon As New ADODB.Connection
Dim rs As New ADODB.Recordset
Case "TITLE"
rs.Open "select * from presilib where title = '" & Trim(txtsearchstring.Text) & "'",
db, 1, 2
Case "AUTHOR"
rs.Open "select * from presilib where author = '" & Trim(txtsearchstring.Text) & "'",
db, 1, 2
Case Else
rs.Open "select * from presilib", db, 1, 2
End Select
Set DataGrid1.DataSource = rs
End Sub
#include <afxwin.h>
class Myframe:public CFrameWnd
{
public:
Myframe()
{
Create(NULL,"SIMPLE DIALOG Box");
}
void OnLButtonDown(UINT flag, CPoint point)
{
char str[100];
sprintf(str,"%d, %d",point.x,point.y);
MessageBox(str, "Mouse position");
}
DECLARE_MESSAGE_MAP();
};
BEGIN_MESSAGE_MAP(Myframe,CFrameWnd)
ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()
#include <afxwin.h>
#include "resource.h"
class myframe : public CFrameWnd
{
public :
myframe()
{
Create(NULL,"menu
program",WS_OVERLAPPEDWINDOW,rectDefault,0,MAKEINTRESOURCE(IDR_MENU1));
}
};
class Myapp:public CWinApp
{
public:
BOOL InitInstance()
{
myframe *bw;
bw=new myframe();
bw->ShowWindow(1);
m_pMainWnd=bw;
return 1;
}
};
Myapp theApp;
Part B
Part B 11. Calculator (Control Arrays)
11. Write a VB program to design a simple calculator to perform addition,
subtraction, multiplication and division (control Arrays)
FileError:
MsgBox "File Error!"
End Sub
FileError:
MsgBox "File Error!"
End Sub
Part B 15.Encryption & Decryption
21. VB program to Encrypt and Decrypt a string.(Use Rnd() to generate the Encryption and Decryption keys.)
i=1
l = Len(txt_encdec)
Do While (i <= l)
encstr = Mid(txt_encdec, i, 1)
dec = dec + Chr(Asc(encstr) - rno)
i=i+1
Loop
txt_encdec = dec
End Sub
If KeyAscii = 45 Then
sign = sign + 1
End If
If KeyAscii = 46 Then
period = period + 1
End If
If period > 1 Then
MsgBox "A number should have only one integral part and one fractional part"
period = period - 1
KeyAscii = 0
End If
If Not Chr(KeyAscii) Like "[0-9]" And Not Chr(KeyAscii) = "." And Not Chr(KeyAscii) = "-"
And Not KeyAscii = 8 And Not KeyAscii = 27 Then
MsgBox "Invalid Keypressed"
KeyAscii = 0
End If
digicount = digicount + 1
If KeyAscii = 8 Then
sign = sign - 1
End If
End Sub