Sunday 23 September 2012

Simple VB 6.0 programs


Program On Predefined Dialogue Box


Caption
Name
File
Mnufile
Display
Mnudisplay
Date
Mnudate
Exit
Mnuexit

 
DESIGN VIEW:
 


CODING:

Private Sub mnudate_Click()
Dim i, day, msg
i = InputBox("enter a date:", "datedemo")
If Not IsDate(i) Then
MsgBox "invalid date"
Exit Sub
End If
day = Format(i, "ddd")
msg = "day of this date:" + day
MsgBox msg
End Sub

Private Sub mnudisplay_Click()
Dim message As String
Dim dialogtype As Integer
Dim title As String
message = "have a gala shopping"
dialogtype = vbOK + vbInformation
title = "welcome to the supermarket"
MsgBox message, dialogtype, title
End Sub

Private Sub mnuexit_Click()
Dim message As String
Dim title As String
Dim dialogtype As Integer
Dim response As Integer
message = "thank you,visit again"
dialogtype = vbYesNo + vbInformation
title = "goodbye"
reponse = MsgBox(message, dialogtype, title)
If response = vbYes Then
End If
End Sub


OUTPUT 1:
 




OUTPUT 2:




OUTPUT 3:



 

 Program using Picture box, Drive, Directory, File list box’s

 
control
Property
value
Form
caption
Open
Label1
caption
Drive
Label2
Caption
Directory
Label3
Caption
File
Command1
caption
Exit
Command1
Font
MS scan serif,12p
Form
Window size
Maximized
Picture1














DESIGN VIEW:
 

CODING:

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()
Dim f As String
f = Dir1.Path & "/" & File1.FileName
Picture1.Picture = LoadPicture(f)
End Sub

Private Sub Form_Load()
File1.Pattern = "*.bmp"
End Sub

OUTPUT:


VB program for creating MDI application


1. Start a new project by selecting file->new project. Select standard EXE as the project type if you have the project wizard enabled.
2. You will already a have a form in the project. Set its name property to formchild and its caption property to MDI child.
3. To create the MDI parent form, right click the forms folder in the project Explore and select add ->MDI form. If the form wizard appears, select MDI form.
4. Set the name property to formMDI and the caption property to MDI parent to MDI parent.
5.  Right click project1 in the project Explorer and select project1 properties from the top-up menu. Set the startup object list to form MDI. If you omit this, the application will start with the child form showing.
6. Select form child from the project Explorer. Set the form’s MDI child property to true. This will case this form, which is the child, to rest inside of the MDI parent container.
7. Select form MDI the project Explorer.
8. Start the menu designer by selecting tools->Menu Editor. You will see a window like the one in
9. Type & file in the caption field.
10. in the name field, type menufile.
11. Click the next button.
12. Click the arrow right button.
13. Enter & new in the caption field.
14. in the name field, type menunew.
15. Click the ok button to close the Menu Editor.
16. The form MDI from should now have a file menu on it. Select file ->New from the MDI menu. this will open up the window.
17. In the private sub menu file New-click () event, type the following lines of code:
18. Save and Run the project.

PARENT FORM:

CHILD FORM:


CODING:

Private Sub menunew_Click (Index As Integer)
Dim Form As New formchild
Form.Show
End Sub

OUTPUT:


Control
Property
Value
Text1
Text
Null
Text2
Text
Null
Text3
Text
Null
Command1
Caption
Clear
Command2
Caption
End




Program for MENU EDITOR:


Caption
Name
Shortcutkey
Add
Mnuadd
Ctrl +A
Sub
Mnusub
Ctrl +S
Mul
Mnumul
Ctrl +M
Div
Mnudiv
Ctrl +D




DESIGN VIEW :







CODING :

Private Sub Command1_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub

Private Sub Command2_Click()
End
End Sub

Private Sub mnuadd_Click(Index As Integer)
Text3.Text = Val(Text1.Text) + Val(Text2.Text)
End Sub

Private Sub mnudiv_Click()
Text3.Text = Val(Text1.Text) / Val(Text2.Text)
End Sub

Private Sub mnumul_Click(Index As Integer)
Text3.Text = Val(Text1.Text) * (Text2.Text)
End Sub

Private Sub mnusub_Click(Index As Integer)
Text3.Text = Val(Text1.Text) - Val(Text2.Text)
End Sub


OUTPUT :


Dragging text from MS-Word into a text box using OLE Drag and Drop


1.      Start a new project using File-> New Project -> Standard EXE.
2.      Place a Textbox on the form.
3.      Change OLEDropMode property of the textbox (Text1) to 1-Automatic.
4.      Run Visual Basic project using F5.
5.      Start MS-Word.
6.      Type some text in word document.
7.      Arrange Visual Basic project and MS-Word side by side.
8.      Select the text in word document and drag the text while holding down ctrl key into textbox of the form.



FORM DESIGN:







No comments:

Post a Comment

Oracle Reserved Words

Oracle  Reserved Words The following words are reserved by Oracle. That is, they have a special meaning to Oracle and so cannot be redefi...