VB Getting started frequently asked questions

Source: Internet
Author: User
Tags definition integer modify pack

What's the difference between SP2, SP3 and Enterprise Edition

Ask the VB in the SP2, SP3, Enterprise version of these three kinds of, each representative what meaning?

The SP is the abbreviation for the service pack. Microsoft each launch a software, will not regularly introduce some patches, according to time successively called SP1, SP2 and so on. The latter SP version includes the entire contents of the previous version, so if you install the SP3 you don't have to install SP2. The Service Pack's Readme file describes what errors the service pack has modified. VB has three major versions: Learning version, Professional Edition, Enterprise Edition. The Enterprise Edition is the most fully functional version and, of course, the most expensive version.

The address of VB home page is:

Msdn2.microsoft.com/zh-cn/vbasic/default.aspx

VB download address is: msdn2.microsoft.com/zh-cn/vbasic/ms789072.aspx

What is the meaning of the API

The API is often encountered in programming. What is the meaning of the API? How do I know the window handle, window class name, etc. often used in programming?

The API is the abbreviation for the application Programming Interface (Application Programming Interface), which is the interface that the application invokes the system function. The Windows API mainly includes functions, messages, and related data types that are defined by the Windows system. We use all kinds of development tools to deal with the API in the final analysis. But the API itself is more difficult to master, so Visual Basic provides Visual object-oriented controls that allow beginners to write Windows programs even if they are not familiar with the API. However, the controls provided by Visual Basic are, after all, limited and cannot include all aspects of the API, so some complex functionality still needs to be invoked to implement the API.

What does the &H in the API definition mean

Q Now I see some routines made with API functions, with one statement: public CONST Lvm_first = &h1000, what does &h1000 mean in this statement?

Answer &H is 16 of the system, such as &h10 equal to the decimal 16.


Why do I always tip "variable not defined"

Ask the following is a small program to shut down Windows:

Option Explicit

Private Declare Function exitwindowsex Lib "user32" (ByVal uflags as Long, ByVal dwreserved as long) as long

Private Sub Form_Load ()

ExitWindowsEx Ewx_force or Ewx_logoff or Ewx_shutdown, 0

End Sub

But when compiling, always prompt: Ewx_force variable undefined, but Ewx_force is a parameter. Why is that?

Answer Ewx_force and several other parameters are constants defined in the Windows API. You use option Explicit (this is a good habit to find errors), so VB finds that undefined symbols are prompted, which helps to find spelling errors and missing parameter definitions. You should copy the definitions of these parameters from the Win32api.txt of VB.

How do I save a picture

Asked me in the main form of VB to load a prior selection of pictures, the program after the operation I can be modified in the picture and save it for later call. How do I do that?

You can set the form or PictureBox Autodraw property to True, modify the SavePicture statement to use VB to save the disk. Such as:

SavePicture picture1.picture, "C:\test.bmp"

This file is a. bmp file with the same number of colors as the current screen. If you have a high requirement for the disk, you want to control the file format, you can only use other controls, such as Imageman (http://www.data-tech.com download), lead Tools (http://www.leadtools.com download) and so on.


"Live error 9 subscript out of Bounds" error

Ask me the following error occurred while assigning a value to an array: "Live error 9--subscript out of Bounds". The code for the error is as follows:

Dim Inputdata () as single

Inputdata (0) = Text2 (0). TEXT/TEXT2 (1). Text Note: Enrollment

May I ask why such a mistake has occurred?

Answer VB must specify the size of the array before using the array. One approach is to determine the size at definition, such as Dim Inputdata (a) as single, and the other is to take a dynamic array. For your program, the array Declaration section can be used without modification, but before the error statement: ReDim Inputdata as single.

How to open a database on a disc

Asked me to make a VB program, when the program engraved on the disc, can not be used, after the inspection found because the. mdb file is read-only, program error: "The database file has been opened exclusively by another user, you cannot access." How do you master? But I can read the database (read-only) with access.

If you use this database with the data control, set the ReadOnly property of the data control to true, and set the exclusive property to True. If the ReadOnly property is False, the error message appears as you see it. If you do not set the exclusive property to True, the error message for the can annotation: T lock file appears. If you are using the OpenRecordset statement to open the database, the exclusive attribute corresponds to the dbdenywrite and Dbdenyread parameters.

How to prevent the current window from being closed

How do you prevent the current window from being closed after you press the close key in the upper right corner?

A form_unload and Form_QueryUnload event occurs when the close key is pressed. Both events have a cancel parameter that prevents the window from being closed if you set it to true during event handling. The Form_QueryUnload event may be better for your problem because it has a unloadmode parameter that distinguishes whether the command that closes the window is made by the user, is made by the system, or is generated by this program code.

Programming problems with DLLs

Ask me to write the ActiveX DLL program for the first time, in the DLL, I only write a function card in the class module, after compiling the DLL, call in another program, declare in the module:

Public Declare Function card_config Lib "C:\test\card.dll" (ByVal address As Integer, ByVal intermit As Integer)

Write the following code in a button:

c = Card_config (12,12)

Error after run: After compiling the ActiveX DLL, an error occurred during the call: "Live error 453, no DLL entry point found" look advice. If possible: Please tell me the programming format of the DLL in detail.

A Declare statement can only be used to invoke a standard DLL, not to invoke an ActiveX DLL, which is why you have a program error. VB cannot generate standard DLLs, only ActiveX DLLs can be generated. To invoke an ActiveX DLL, you typically call it through the CreateObject statement, or select the menu "Project/reference" in the integrated environment, and in the dialog box, select the ActiveX DLL you want to invoke. This allows you to use the object or function defined in the ActiveX DLL in your program.

How to start another application

Ask how to start other Windows applications in VB, such as Notepad?

You can use the VB Shell function to invoke other applications. Such as:

Shell "Notepad.exe C:\autoexec.bat"

How to print MSChart

Ask how to print the contents of a MSChart control?

The MSChart itself does not have the printing function, so you must first use EditCopy to put the image on the Clipboard, and then print, such as:

Mschart1.editcopy

Printer.print″″

Printer.paintpicture clipboard.getdata (), 0, 0

Printer.enddoc

What does "can′t find DLL entry point" mean?

What do you mean by asking for the following error message? "Run-time Error Note: 453 Note: can comment: T find DLL entry point openprocess in kernel 32", (I have a definition of private Declare Function Openproc ESS Lib "kernel32" (ByVal dwdesireaccess as Long, ByVal binherithandle as Long, ByVal Dwprocessid as long) as long

Answer the OpenProcess to OpenProcess. Because the name of the function in the DLL is case-sensitive under win 32. There is only openprocess function in kernel32, no openprocess function.

"Object does not support this property or method" error

Ask why the object does not support this property or method error when executing Data1.Recordset.FindFirst "pubid=" & Dbcombo1.boundtext?

This is because methods such as FindFirst, FindNext, findlast do not support the recordset of the table class, but you can use the Seek method to find work. But you have to index the PubID field. If you want to use the FindFirst method, modify the Data1 RecordsetType property to dynaset.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.