1. If a line of programs are too long, it is very troublesome to find it, can you change?
The VB program code is allowed to write, as long as the last character of each wrap is added to the wrap character "_". For example: SUB PICMove () frm.picture2.Left = frm.picture1.LEFT _ 'plus newlinefrm.picture1.widthend Sub
2, how to empty the existing picture when design?
Use the Picture property in the property window in the Properties window, press Del to clear the picture.
3, how do Visual Basic notes a longer program code?
The symbol of the VB comment program code is "'", as long as "'" is added in front of a single line, you can comment. However, if the program code is long, a line of comments feel unbearable. The VB itself provides this feature. Under the "Toolbar" of the main menu "View" option, select the Edit, VB interface, a row of tool buttons, two buttons after the hand-shaped button are used for "Settings Comment Block "And" Release Notes Block ".
4, how to achieve the function of a small prompt window in one movement of the mouse?
Each control in VB has a tooltiptext property, just plus a line of programs. For example: label1.tooltiptext = "This is a prompt!".
5, how to get the current software running disk directory and command line parameters?
There is a system object called app in VB. App.path is the current software running directory. The command line parameter is stored in a system variable, called Command. The program statement is as follows: label1.caption = app.path label2.caption = Command $
6, I want to change the shape displayed in the mouse, how to do it?
The system controls provided by VB generally have MousePointer and Mouseicon properties. We can look for our favorite * .ico, *. Cur files, the procedures implemented as follows: Screen.MousePointer = 99 'User Mouse Type Screen.Mouseicon = LoadPicture ("c: /abc/1.ico")' Read the mouse Icon file
7, how to set the program's error exit?
The ON ERROR statement is used for the error outlet processing of the program. There are two types of general treatment methods. 1) I have encountered an error to go to a row program to execute, and ON Error Goto Someline. For example: on error goto err_line ... label1.caption = "correctly" Err_Line: ... Label1.caption = "error!" 2) Ignore the current error after encounter an error, continue to execute, on Error Resume next. For example: on error resume next ... label1.caption = "No matter what to do" ...
8. How to get the keyboard input and judgment the ASCII value of the key?
Set the keypreview property of the form to TRUE, then write program code in the form_keypress event as follows: private subform_keypress (keyascii as integer) me.caption = str (keyascii) 'get the keyboard input character ... End Sub
9, I hope that the form is running on the center of the screen, how to achieve it?
The VB system object Screen records the height and width of the current display mode, which can utilize this value to set the location of the form. Sub Centerform (frM as form) 'defined process frm.move (screen.width - frm.width) / 2, (Screen.Height - frm.height) / 2 end sub private sub form_load () centerform me' calling process End Sub10 Many software have the mouse in the text box TextBox, and how is the functionality of all text?
PRIVATE SUB TEXT1_GOTFOCUS () text1.selstart = 0 text1.sellength = len (text1.text) 'Procedure calling End Sub
11. How to shield the keyboard input of the list box COMBO?
Private sub combo1_keypress (keyascii as integer) keyascii = 0 'ASCII code is 0 characters are empty operation End Sub
12, how to make a string of strings vertically?
'Custom Function RotateString: Vertical Display String Function RotateString (In_Str As String) AS String Dim Tmpstr AS String' Take each character to add a Running Wrap symbol for i = 1 to LEN (in_str) TMPSTR = TmpStr MID $ (in_str, i, 1) & vbcrlf 'VBCRLF is the Entering Renewal Next I Rotatestring = Tmpstr End Function' Function Call Private Sub Form_Click () Label1.caption = RotateString ("Do you know I am here?") End Sub
13. I want to press the right mouse button in the form to pop up a menu. How do you do?
First press the menu editor to design a menu popmenu, set the Visible of the menu to False. The writing programs in the Form_MouseDown event are as follows: if button = 2 'mouse button Press PopupMenu Popmenu End if
14. How do you transform each other in Visual Basic?
VB provides system functions Val () and STR (), which can be used to achieve conversions between integers and strings. Examples are as follows: SUB STR2INT () DIM INT1 AS INTEger DIM STR1 AS STRING INT1 = 100 STR1 = STR (INT1) 'Integer Convert into string Debug.print str1 str1 = "400" int1 = val (str1)' string conversion to Integer debug.print INT1 End Sub
15. Can I execute the program code for other forms in a form?
Yes, we can use the "form. Code" mode to perform the code of other forms. First assume that I want to perform form fRM1 in the form fRM2, the program is as follows: private subform_click () frm1.form_click () 'Perform FRM1 in FRM2 from_click code End Sub
16. How to prevent the array range without changing the array content?