Home > Software engineering >  VB a form of show events
VB a form of show events

Time:09-20

In the following code
1) why do you want to use the show statements?
2) the CRH (9) what meaning be?

1
 option baseDim a (3, 3) as an integer 
Private sub command1_click ()
Dim s as integer
S=0
For I=1 to 3
S=s + a (I, I)
Next
Sum of the diagonal picture1. Print "is:"; S
End sub

Private sub form_load ()
The show
Randomize
For I=1 to 3
For j=1 to 3
A (I, j)=int (Rnd * 99 + 1)
Picture1. Print a (I, j); CRH (9);
Next I
Picture 1. Print
Next I
End sub

CodePudding user response:

The
reference
1) why do you want to use the show statements?
2) the CRH (9) what meaning be?


No installation VB on the computer, so can't test, Show the meaning of is to display the form, the load event is shown by default form, if the form no hidden elsewhere should be take out this sentence,
CRH (9) is equivalent to press the TAB key keyboard, its ASCII is 9

CodePudding user response:

Show call first display the form, otherwise, the print will show later, you will see the word form output, you try, you will know,
CRH (n) is the output ASCII code n characters, ASCII table you can check on your own, 9 represents a tabs, it is a blank, make the next output like table and aligned above,

CodePudding user response:

reference 1st floor leon51 response:
reference
1) why do you want to use the show statements?
2) the CRH (9) what meaning be?


No installation VB on the computer, so can't test, Show the meaning of is to display the form, the the load event is the default display of the form , if the form no hidden elsewhere should be take out this sentence,
CRH (9) is equivalent to press the TAB key keyboard, its ASCII is 9

The load only "load", doesn't mean to be displayed,
But if you want to "show", will first load,
Only the "load action" will be "implied operation" :
If at the time of the show, the form without load, then it will be "automatic load"; Has the load directly can show,
(in fact is not automatic, just in the process of the show interface is detected in no load, it will help you load)

This passage "sounds" a bit around the mouth, but also it is easy to understand,
Can use a simple code confirmed:
Create a new standard EXE engineering ", "Form1 form in picture two buttons, add a form Form2,

 'two command buttons for Form1, write the following event code: 
Private Sub Command1_Click ()
The Load Form2
End Sub

Private Sub Command2_Click ()
Form2. Show
End Sub

'-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
'only the following events in Form2 code:
Private Sub Form_Load ()
MsgBox "loading Form2," 64 & amp;
End Sub


To run the program, and then in the following:
1. Point Command1, message box,
Point sure close the message box, to continue to point Command1, but not "respond" :
Because Form2 are loaded just now, later, already won't trigger Form2 Load event,
But Form2 merely "load", will not be displayed!
2. At this time point Command2, Form2 window display immediately, but at this time also won't appear before displaying the form message box,
3. Point Form2 window in the top right corner of the "x" to close the window; Point Command2 again, you can see:
First message box: because just closed Form2, Form2 will be UnLoad, now to do the Show, so you have to Load it,
Point in the message box "sure", after the Form2 can be displayed immediately,
4. Cut the activity form to Form1, at this point to point in the Form1 Commnad1, there will be no reaction, because is already loaded Form2;
Point Command2 right now, "activity form" will become Form2, because after the Show will activate the corresponding form,

CodePudding user response:


Show method


To show the MDIForm or the Form object, does not support named parameters,

Syntax

Object. The Show style, ownerform

Show method syntax includes the following parts:

Part of the description
Object optional, an object expression, its value is "applied" in the list of an object, if you omit the object, the default is associated with activity form module form object,
Style optional, an integer, it is used to determine the form mode or not, if the Style is 0, the form is no pattern; If the style is 1, the form is pattern,
Ownerform optional, string expression, and points out that the component's form is displayed, for a standard Visual Basic form, using keywords Me,


Description

If the call Show method when the specified form is not loaded, Visual Basic will automatically load the form,

When the Show shows no pattern form, and then meet the code is to be performed, when the Show on the display mode form (modal form), the subsequent code until the form is hidden or unloaded to execute,

When the Show on the display mode form, in addition to the model objects in the form cannot be input (keyboard or mouse click), the other form to input before the program must hide or uninstall mode form (usually in response to user some operating status), MDIForm can't be in the form of,

When model window display, while other forms of application failure, but other applications will not fail,

Application startup form after the call will automatically appear in the Load event,

The following example shows how to use ownerform parameters:

Private Sub cmdShowResults_Click ()
'display mode form frmResults.
FrmResults. Show vbModal, Me
End Sub
  • Related