Académique Documents
Professionnel Documents
Culture Documents
Form Create
VB Bar Code
Form File
Sub Focus
Level:
Application Forms
VB6 to VB Net
VB
Navigate To
Home
Written By TheVBProgramer.
Tutorials
Source Code Samples
VB.NET Tutorials
Add Your Tutorial
Forums
Articles
External Links
Advertise Here!
Contact Us
Guides
The Show method of a form displays that form on the screen. If the
form to be shown is not already loaded into memory, the Show
method will load it before showing it. The Show method is typically
used to transfer control from one form to another. The syntax is:
formname.Show
For example, if I am in Form1 and I want to display Form2, the
syntax would be:
Form2.Show
Beginner Guide
Controls Guide
Understanding forms
Timer control
Multiple Forms
Everything Images
Control arrays
When you display one form from another, you may want the user to
complete work on that form before returning to the first one. This
does not happen automatically. By default, VB will display the
second form and then continue executing code from the first form.
To suspend execution of the first form until after the second form is
done with, add the keyword constant vbModal as an argument to
the Show method. The syntax is:
Option Buttons
Check Boxes
Math Game
(o) Hangman
(o) Tic Tac Toe
(o) Calculator
(o) Cryptogram
Form2.Show vbModal
The Hide method of a form removes the form from the screen
(makes it invisible), but the form still remains in memory. The syntax
is:
formname.Hide
(o) Concentration
Database Guide
User login
Username: *
Form1.Hide
Password: *
As an alternative, you can use the keyword Me. The keyword "Me"
refers to the form in which code is currently running:
Log in
Create new account
Request new password
Me.Hide
Finally, any time you want to execute a method of the form on itself,
you can simply code the method name, omitting the "formname." or
the "Me.", as in:
Hide
Load formname
The Unload statement removes a form from memory and from the
screen. When you code the Unload statement for a form, the
Form_Unload event of that form will be triggered. The syntax is:
Unload formname
A form can unload itself, as in:
Unload Me
The Unload event is also triggered with the user clicks the Windows
"close" button ("X") on the form.
Try this:
End Sub
(2)
Assume you have a project with three forms: Form1, Form2, and
Form3. (To add forms to a project, go to the Project menu and
select Add Form.) Form1 serves as the switchboard form, which
contains three command buttons: cmdForm2, cmdForm3, and
cmdExit:
For the sake of the example, Form2 and Form3 simply contain one
button with the caption "Return to Main Menu". The code behind the
command button on each of these forms is simply Unload Me.
When either of these forms is unloaded, the main menu form will
then become the active form.
Description
Centers a form on the screen. This
Sub has been used in previous
examples presented on this site.
Usage: CenterForm FormName
(where FormName is the name of the
form without quotes (e.g. Form1) or
the keyword Me)
To center the current form, you would
use:
CenterForm Me
FormIsLoaded
EnableFormXButton
GetMenuItemCount, RemoveMenu,
DrawMenuBar).
Usage: EnableFormXButton
FormName, BooleanValue
(where FormName is the name of the
form without quotes (e.g. Form1) or
the keyword Me and BooleanValue is
True or False)
To disable the X button on Form1,
you would use:
EnableFormXButton Form1, False
MakeTopmost
LockWindow /
UnlockWindow
Const
Const
Const
Const
Private
Private
Private
Private
Const
Const
Const
Const
'=============================================================================
' Form-related Routines
'=============================================================================
'---------------------------------------------------------------------------Public Sub CenterForm(pobjForm As Form)
'---------------------------------------------------------------------------With pobjForm
.Top = (Screen.Height - .Height) / 2
.Left = (Screen.Width - .Width) / 2
End With
End Sub
'---------------------------------------------------------------------------Public Function FormIsLoaded(pstrFormName As
String) As Boolean
'---------------------------------------------------------------------------Dim objForm As Form
For Each objForm In Forms
If objForm.Name = pstrFormName Then
FormIsLoaded = True
Exit Function
End If
Next
FormIsLoaded = False
End Function
'---------------------------------------------------------------------------Public Sub EnableFormXButton(pobjForm As Form,
pblnEnable As Boolean)
'---------------------------------------------------------------------------Dim lngSysMenuID As Long
Dim lngMenuItemCount As Long
' Get handle To our form's system menu
' (Contains items for Restore, Maximize, Move,
Close etc.)
lngSysMenuID = GetSystemMenu(pobjForm.hwnd,
pblnEnable)
If lngSysMenuID <> 0 Then
' Get System menu's menu count
lngMenuItemCount =
GetMenuItemCount(lngSysMenuID)
If lngMenuItemCount > 0 Then
' Remove (hide) the "Close" item itself (the
last menu item) ...
RemoveMenu lngSysMenuID, lngMenuItemCount - 1,
MF_BYPOSITION Or MF_REMOVE
' Remove (hide) the seperator bar above the
"Close" item
' (the next to last menu item) ...
RemoveMenu lngSysMenuID, lngMenuItemCount - 2,
MF_BYPOSITION Or MF_REMOVE
End If
End If
DrawMenuBar pobjForm.hwnd
End Sub
'----------------------------------------------------------------------------
Similar links
Cara Memperbesar Buah Dada
entre otros.Bootcamp Gesundheit
Babak Final Liga Champions 2013
Prediksi Getafe vs Real Sociedad
Cara Terbaik Mengatasi Ejakulasi Dini
Cewek Cantik Kelihatan Celana Dalam Tanpa Sensor
Pantun Jenaka
Yoyoipads.com - get free ipad anywhere
- ?
Subscribe
I made 5 forms.... one is main form and the other four is sub-forms.... how can i open the
four sub-forms randomly with just clicking a button? what code should I use to open it
randomly?
reply
about form1
hey thank you very much.i had got answer of my question which i was finding in many
places in this page
reply
I'm having weird experience with multiple form, not solved yet.
I have 3 forms.
1 main form => opening child form (sales form) => opening child form (search items)
all the child forms containing listview with in frame.
If I call the search items and close the form, it will leave line artifact on the sales form,
the line is black solid horizontal line the same width the search item form width along the
frame containing the listview
on the sales form.
How to avoid it? Sometimes it really annoying.
thank you.
reply
VB
guide
how to define user defined names in login form that verify wit database in vb coding..
give me syntax for same
reply
window.onbeforeunload =
window.onbeforeunload = function(e) {
// confirm('Are you sure you want to leave?');
if (confirm('Are you sure you want to leave?'))
alert('YES');
else
alert('No');
//else alert('A wise decision!')">
}
refer from http://www.codeprojectdownload.com
reply
hi
am can you please show the easiest purchasing system and has a inventory ?
reply
about form
how to creating data from one forms and retrieving data from another form Using
VB6.0.............pls reply me.......
reply
Implicit Loading -
If I try to access any property of a child form ( still NOT loaded in memory ) from a MDI
Form, the child form is automatically loaded into memory.
I wish to access these property WITHOUT the form automatically loading.
Refer to below code.
in the line " If objForm.Name = Myform.name Then", the result is always true because the
moment VB engine encounters "Myform.name", it automatically loads this form into
memory and returns "True". Thus I am unable to determine if "Myform.name" was loaded
in memory before execution of this procedure or not.
"Public Function FormIsLoaded(pstrFormName As String) As Boolean" referred in above
snippet fails.
************************
Public Sub CheckFormStatus(Myform As Form)
' This procedure determines if "frm_by_code" is open in the background when
' "frm_by_name" is exited. If yes, it displays "frm_by_code" before exiting.
Dim objForm As Form
Dim FormLoaded As Boolean
Dim FormShown As Boolean
FormLoaded = False
FormShown = False
For Each objForm In VB.Forms
If objForm.Name = Myform.name Then
FormLoaded = True
If objForm.Visible Then
FormShown = True
MsgBox "Load Status: " & FormLoaded & vbCrLf & "Show Status:" & FormShown
' Myform.Show
End If
Exit For
End If
Next
End Sub
reply
Clicking first Menu Tab will display Form X & clicking the other Tab will display Form Y.
If i run VB.Forms.count at start of project, it shows 1 form is loaded ( the MDI form ).
Now if I click Menu Tab "X", Form X loads.
Now vb.forms.count shows 2 forms are loaded ( MDI form & Form X ).
Now I exit Form X by issuing "unload me" command, the form disappears and control
returns to MDI application.
Then I click Menu Tab X again.
Now vb.forms.count shows 3 forms are loaded ( MDI form , Form X & Form Y )!!!!!!!!!!!!!!!
I do not know how Form Y is loaded since this form has not been loaded / activated till
now.
Can anyone help me on this ?????
reply
I am using one text box, one label and one command button, i am inserting a numeric no
and pressing command the numerical number is displayed in label like wise i enter
several nos and it will go on adding in the label. i need a help when i close and open the
software the last value in the label should be displayed.
Thanks
sampath
reply
Hi, I am new to VB6. I created the vb6 project connecting with a MySQL database. It is
working fine. Now I want to print that vb forms. In that MySQL database some fields are
empty. In the VB6 forms same text boxes are also empty. How can I hide those text boxes
& remove that space and re-size the form in printing.
eg.
Name Tel.No
xxxxx 12345
bbbb
ccccc 56789
tvsh
reply
Help me,
i need to send text from button1 in form2 to button1 text in form 1.
Form2.Button1.Text = Form1.Button1.Text
I tried this but its not usable. Can any one help me on the code.
Hope you guys will help me.
Have a nice day.
Thanks in advance.
Mu2
reply
use caption
use caption ;)
form1.button1.caption="wowowowow"
form2.button2.caption = form1.button1.caption
bye
Marco Gianelli
reply
Hey..Thanks..
I've got 2 forms, form1 and form2. I want to display form2 on form1 and not in another
window, upon clicking the command button.
please help.
reply
i am doing my project in VB6 i used image control and i put picture on that control but
when i opened my project on other computer the image is not in that control.. why it is
happen?
reply
i am doing my project in VB6 i used image control and i put picture on that control
but when i opened my project on other computer the picture is not in that control..
why it is happen?
reply
End Sub
Private Sub FindButton_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles FindButton.Click
blnfound = False
inttotrec = Stock_In_OutDataSet.Tables("REP QUOTE").Rows.Count
'Moves the record pointer to the first record
'which has a row index number of zero
introws = 0
'Converts the value of the first record of our chrfname field to capital
'letter and assign it to a variable named strname
strname = Stock_In_OutDataSet.Tables("REP QUOTE").Rows(introws).Item("JOB
DESCRIPTION")
'Converts the text entered in our search textbox to Uppercase
'The purpose of converting both record values and search text to upper case
'is to compare both values in uppercase form regardless of whatever
'case they were typed initially
strtext = UCase(JobNameTextBox.Text)
'If the searchtext is equal to our record then
If (strtext = strname) Then
'assign true to our blnfound variable
'will be used later whether to display or not
'to display our message box
blnfound = True
'display the record values on their corresponding controls
JobLabel.Text = Stock_In_OutDataSet.Tables("REP QUOTE").Rows(introws).Item("JOB
DESCRIPTION")
CustomerNameLabel.Text = Stock_In_OutDataSet.Tables("REP
QUOTE").Rows(introws).Item("CUSTOMER")
QuoteNumberLabel.Text = Stock_In_OutDataSet.Tables("REP
QUOTE").Rows(introws).Item("QUOTE NUMBER")
End If
'if not equal to the first record then
While (strtext <> strname) And (introws < inttotrec - 1)
'increment the record pointer
introws = introws + 1
'assign the value of the next record pointer to strname
strname = UCase(Stock_In_OutDataSet.Tables("REP QUOTE").Rows(introws).Item("JOB
DESCRIPTION"))
'tests if the next record value is equal to the search text
'if yes then
If (strtext = strname) Then
'assign true to our blnfound variable
blnfound = True
'display the record values on their corresponding controls
JobLabel.Text = Stock_In_OutDataSet.Tables("REP QUOTE").Rows(introws).Item("JOB
DESCRIPTION")
CustomerNameLabel.Text = Stock_In_OutDataSet.Tables("REP
QUOTE").Rows(introws).Item("CUSTOMER")
QuoteNumberLabel.Text = Stock_In_OutDataSet.Tables("REP
QUOTE").Rows(introws).Item("QUOTE NUMBER")
End If
'Continue incrementing the record pointer until a match is found
'and the end of file has not been reached
End While
'if the record is not found, display Record not found in our messagebox
If blnfound = False Then
MsgBox("Record not found", MsgBoxStyle.Information, "Search a Record")
End If
End Sub
Private Sub JobNameTextBox_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles JobNameTextBox.TextChanged
End Sub
Private Sub ViewQuoteButton_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ViewQuoteButton.Click
Dim currentRow As Integer
currentRow = Stock_In_OutDataSet.Tables("REP QUOTE").Rows(introws).Item("QUOTE
NUMBER")
Form1.PrintDocument2.Print()
End Sub
End Class
When i press the "View Quote" button, i want to view the quote as if i just pressed the
"print" button in Form1. It does that but does not print the selected quote, it generates a
new quote. ANY idea what im doing wrong ? (Also a new=bie)
reply
Hello friends
I want to make a web browser in vb but it should work offline because I have not internet
connections. Any Suggestions?
reply
can you help me out? how to edit a combo box list in form1 from form 2? for
example...there is this form where there is a combo list of movies,form1, and there is
another form, form2, where you can edit what is the price and the movies in the combo
list of form1....
reply
help me
plz send me full toturial about how to display data on form 2 base on the searching from
form1.
i have created a database in microsoft access 2007.
reply
(if a standard module is the startup object, it must contain a public subroutine called
"Main", and "Sub Main" is specified for the Startup object)
This is not true. In fact, you should rarely ever use Public for Sub Main. It should almost
always be Private.
reply
Hi i have created a database in SQL Server and need to import it in to visual basic so
that i can create different forms that the user will be able to search for data or display that
data that the user has searched. Can anyone please help i need this for a project i am
doing for university.
thanks
reply
Hi
reply
Need help.
I have a form (form1) that contains a field (text1). For "text1", if I key-in a value, it will
search into database. But if it doesn't find in the database, it will load another form
(form2). In the form2, it will display all the records from the database. After we choose a
record in form2, form2 will return a value back to field "text1" in form1.
Form2 is not just being called from form1. It may be called from another forms. So I need
to know how form2 return a value back to a field (from another form) that called form2.
Can someone help me?
Thx.
WT
reply
Hi!
In this example I've used ListView to display the list of records.
Please see below.
'Place this code after the query returned 0
'If rsRecord.RecordCount = 0 Then
Dim oForm As New Form2
oForm.SourceTextbox = Me.Text1 'source textbox where the selected record id
will be returned
oForm.Show 1
Set oForm = Nothing
Form2 Code
Option Explicit
'Here is the source textbox where the selected record id will be returned
Private m_sourceTextbox As TextBox
'This method is use to set the source textbox
Public Property Let SourceTextbox(ByVal source As TextBox)
Set m_sourceTextbox = source
End Property
Private Sub Form_Load()
With Me.ListView1
.ColumnHeaders.Add , , "ID"
.ColumnHeaders.Add , , "Last Name", .Width * 0.4
.ColumnHeaders.Add , , "First Name", .Width * 0.4
.ColumnHeaders.Add , , "Middle Name", .Width * 0.4
.ListItems.Add , , "1"
.ListItems.Add , , "2"
.ListItems.Add , , "3"
End With
End Sub
'If the user's click the record on the ListView it will assign the selected record id on
If you load your database in Form2 throught a listview, then the code for returning
the value to Form1's text1 is:
Form1.Text1.Text = ListView.ListItem(I)
I don't know how the database is loaded in Form2. But the main idea for the code to
send the value from Form2 to Form1 is:
Form1.Text1.Text = (the chosen data)
reply
help!
hey guys,
can anyone help me out with procedures to create a purchase order form using vb6.0??
i am totally new to thiz. do anyone have an idea of it???
thankz
reply
help
End With
Next i
''''What to put on this line?? I need the form to show with the content and edit it before it
update'''
UpdateNameEntry
End If
reply
Push the contro array data into a File. Read the file into arrays before display. There
is no problem of doing this during run time.
If this does not satisfy u, pl elaborate ur problem.
reply
how could i link a login page ( User name and password) with a main menu page which
consist of few optional buttons( such as member registration, member details and back to
main menu) to proceed further?
reply
Hi! Toch,
Yes! It is possible to pass a parameter for Form1 to Form2.
Just follow these steps/procedures.
1.) On your Form2 create a Property Get and Let so that your be able to pass the
value of the textbox on the Form1 w/c holds the jpg filename.
Ex.
On Form 2 (Codes).
Option Explicit
Private m_FilePath As String
Property Let ImagePath(ByVal FilePath As String)
m_FilePath = FilePath
End Property
Property Get ImagePath() As String
ImagePath = m_FilePath
End Property
Private Sub Form_Load()
Call DisplayPicture
End Sub
Private Sub DisplayPicture()
With Me
.Image1.Picture = LoadPicture(ImagePath)
End With
End Sub
2.) After you have created your own Let and Get properties. Here's what you gonna
do next.
Ex.
On Form 1 (Codes)
Option Explicit
Private Sub cmdShowNextForm_Click()
Dim oNextForm As Form2
Set oNextForm = New Form2
With oNextForm
.ImagePath = Me.Text1.Text
.Show 1
End With
Set oNextForm = Nothing
End Sub
There you have it.
Regards,
tobz
reply
I found a reference about this but in the form of Access and not VB6,
http://www.fmsinc.com/free/NewTips/Access/accesstip13.asp
Also, I learned how to determine which form called the form in focus, by using
vbModal on Form.Show
Form1.Show vbModal, Me.Name
The question now is that, when if Form2, how do we extract the parameter passed
"Me.Name"?
reply
remove button
hi this site is great! I've learned so many things on this site.. my question is: how do
remove an action button(radio button) using command button.
thank you very much!
reply
re sizing a form
help
my problem is whit object Forms, because Forms is for form loaded, but I need know how
load the form or how list all objects forms loaded or unloaded, I need your help
reply
I have the focus set to the command button, but I am not sure how to have the command
button selected so that the frame assigned to it is visible. Reasoning for this is due to 1
form with 7 command buttons each with a different frame containing commands specific
to the task selected.
reply
how do i create a form during runtime using vb 6.0? i created runtime controls and their
events using "withevents" but this method is not working with forms. please help me out
asap.
thanx
reply
AM trying to create a system in VB which will store all the data that is enetered by the
user for a particular customer, where customer will purchase some items.I want now to
generate the bill for the same.Am using Access as backend,can anyone suggest how
can i do that?
reply
Code Output
What is the output for the following two codes?
1. Dim intCounter, intNumber As Integer
Private Sub cmdDisplay_Click()
intNumber = 100
For intCounter = 0 To 20 Step 5
intNumber = intNumber 10
Print intNumber
Next intCounter
End Sub
2. Dim intCount, intNum As Integer
Private Sub cmdDisplay_Click ()
intNum = 9
For intCount = 1 To 10 Step 2
intNum = intNum + intCount
Print intNum;
Next intCount
End Sub
reply
VB
the out put after running ten times with 2 step is 180
reply
Extra VB activities
Hi. I teach VB and i need a project on using combo boxes and the for loop. It may also
contain an If function and option buttons. Do you have any? Thanks a lot.
reply
HELP
Hi,
I have one question, and please answer me on the email: hacker524@hotmail.com...
If I have one form1 = Maximazed, and one button on it that show form2. When I click on
that button, form2 will show and you can click form1 but form2 will not hide. Please this is
my only qustion, and need answer.
Btw. Great tutorial
Greetz
reply
help
answer
i am learning visual basic 6 right now, thanks for this easy-to-follow basic tutorial
reply
Hi
I was just passing through and noticed these characters in the vbcode on this web
page!
This is a problem caused by the "MS Frontpage HTML editor". These strange characters
are only ment to be just the dash character.
Example: Replace this charcter: with this dash: Bye.
reply
Help
Ok I dont get anything at all about Vb could some on please help me or teach me step by
step
reply
pl send me tutorial on
my
I got error
Hi, I've been working with your tutorial since from its beginning and it is very nice, but I
need to ask you why I got error (Sub or Function not defined) when I put CenterForm Me
under Private Sub Form_Load() of frmForm 1. Second thing is the alignment of the form
on the screen, when I put error appeared (Compiled error); by the way how to
encode those special characters using keyboard? ok thank you very much for spending
your time and sharing knowledge with us...more power buddy!
reply
about link
hello..i'm new bie in vb..i want to develop a system..so I have a form that has many button
like menu button..so,how can I make that when I click a link button, it shown in the same
form not link to other form..example,my menu form name form1 and has button update,
delete and add. Form for button update name is form2.when I click button update,form2
is target at form1 means everything is shown at form 1.Same happens to other
button..please help me a.s.ap..tq...:)...
reply
The content of this field is kept private and will not be shown publicly.
Homepage:
Subject:
Comment: *
Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
Lines and paragraphs break automatically.
You can enable syntax highlighting of source code with the following tags: <code>,
<blockcode>. The supported tag styles are: <foo>, [foo].
Preview
Unless otherwise noted, all content on this site and in the source samples is Copyrighted
2011 by the owner of vb6.us. All rights reserved - Contact Information