Private Const SWP_DRAWFRAME = SWP_FRAMECHANGED Private Const SWP_HIDEWINDOW =& H80 Private Const SWP_NOACTIVATE =& H10 Private Const SWP_NOCOPYBITS =& H100 Private Const SWP_NOMOVE =& H2 Private Const SWP_NOOWNERZORDER =& H200 Private Const SWP_NOREDRAW =& H8 Private Const SWP_NOREPOSITION = SWP_NOOWNERZORDER Private Const SWP_NOSIZE =& H1 Private Const SWP_NOZORDER =& H4 Private Const SWP_SHOWWINDOW =& H40 Private Const HWND_BOTTOM = 1 Private Const HWND_TOP = 0 Private Const HWND_NOTOPMOST = -2 私有Const HWND_TOPMOST = -1 ''如果您选择,您可以放置定位 ''代码。 In this example the code is placed in the form’’s ’’ load event. ’’ If you want to stop a form from being the topmost window, ’’ simply replace the HWND_TOPMOST constant with the ’’ HWND_NOTOPMOST constant. Private Sub Form_Load() ’’ A long to hold the return value of the SetWindowPos ’’ API. Dim lngRetVal As Long ’’ Set the form to be the topmost window. lngRetVal = SetWindowPos(Me.hwnd, HWND_TOPMOST, 0, 0, _ 0, 0, SWP_NOSIZE Or SWP_NOMOVE) End Sub Question I have a situation where I need to load a form by its name rather than simply creating an object variable. How can I do this? ________________________________________ Answer There are definitely some circumstances where one would need to load a form by its name. Not getting into those circumstances, here is how it’’s accomplished: Public Sub LoadFormByName(ByVal sFormName As String) Dim frm As Form Set frm = Forms.Add(sFormName) frm.Show End Sub Of course, adequate error handling should be added to the procedure to ensure the app doesn’’t crash if the form referenced in sFormName doesn’’t exist. Question I have a form called MyForm. I’’d like to create multiple instances of this form, but when I do MyForm.Show it creates a single instance and manipulates that single instance. How can I create multiple instances of MyForm? ________________________________________ Answer You need to use form variables to accomplish this. Here is a short sample showing how you might create 3 separate and distinct instances of a form named MyForm. Public Sub Show3Forms() Dim f1 As MyForm Dim f2 As MyForm Dim f3 As MyForm Set f1 = New MyForm Set f2 = New MyForm Set f3 = New MyForm f1.Show f2.Show f3.Show End Sub Question On a login form, I have a combo box with 2 entries that will allow the user to select which DB environment they wish to work in. On start up I want the combo box to have "Production" show as the default selection. I cannot seem to have this happen. Everytime the form loads the user must click the arrow to make a selection. ________________________________________ Answer Try adding this code. If cboEnvironment.ListCount 0 Then cboEnvironment.ListIndex = 0 End If Question I’’ve been trying and searching and cannot find any information explaining how to disable the "X" in the upper right hand corner in an MDI child form. Any ideas? ________________________________________ Answer ’’ *** Begin APIs for removing the close button from the control box. ’’ Menu item constants. Private Const SC_CLOSE As Long = &HF060& ’’ SetMenuItemInfo Mask constants. Private Const MIIM_STATE As Long = &H1& Private Const MIIM_ID As Long = &H2& ’’ SetMenuItemInfo State constants. Private Const MFS_GRAYED As Long = &H3& Private Const MFS_CHECKED As Long = &H8& ’’ SendMessage constants. Private Const WM_NCACTIVATE As Long = &H86 ’’ User-defined Type to contain menu info. Private Type MENUITEMINFO cbSize As Long fMask As Long fType As Long fState As Long wID As Long hSubMenu As Long hbmpChecked As Long hbmpUnchecked As Long dwItemData As Long dwTypeData As String cch As Long End Type ’’ Declarations for retrieving and setting menus and menu info. Private Declare Function GetSystemMenu Lib "user32" ( _ ByVal hWnd As Long, ByVal bRevert As Long) As Long Private Declare Function GetMenuItemInfo Lib "user32" Alias _ "GetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, _ ByVal b As Boolean, lpMenuItemInfo As MENUITEMINFO) As Long Private Declare Function SetMenuItemInfo Lib "user32" Alias _ "SetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, _ ByVal BOOL As Boolean, lpcMenuItemInfo As MENUITEMINFO) As Long ’’ A long to contain the handle to the menu we are manipulating. Private hMenu As Long ’’ A menuiteminfo type used for passing to API calls. Private MII As MENUITEMINFO ’’ A constant used for changing the ID of the menu item. This is done ’’ because VB will reset our changes if we leave the ID alone. Const xSC_CLOSE = -10 ’’ This function is used to send messages to windows. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As _ Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As String) As Long ’’ *** End APIs for removing the close button from control box. Private Sub Form_Load() ’’ Disable the close button in the control box. Dim Ret As Long Dim lngOldID As Long ’’ Retrieve the menu item info. hMenu = GetSystemMenu(Me.hWnd, 0) MII.cbSize = Len(MII) MII.dwTypeData = String(80, 0) MII.cch = Len(MII.dwTypeData) MII.fMask = MIIM_STATE MII.wID = SC_CLOSE Ret = GetMenuItemInfo(hMenu, MII.wID, False, MII) ’’ Set the state to disabled and greyed. MII.fState = MFS_GRAYED ’’ Store the old ID. lngOldID = MII.wID ’’ Change the ID. MII.wID = x SC_CLOSE ’’ Indicate to the structure that we are changing the ID and the state. MII.fMask = MIIM_ID Or MIIM_STATE ’’ Set the menu item to the new value. Ret = SetMenuItemInfo(hMenu, lngOldID, False, MII) ’’ Send the WM_NCACTIVATE message to the form so it updates the control box. Call SendMessage(Me.hWnd, WM_NCACTIVATE, True, 0) End Sub Question How do I get the name of the logged on user? ________________________________________ Answer Option Explicit ’’ The first thing to do is to declare the proper API ’’ function, as follows: Private Declare Function GetUserName Lib "advapi32.dll" _ Alias "GetUserNameA" (ByVal lpBuffer As String, nSize _ As Long) As Long ’’ Now we need a function which calls the API we just ’’ declared and then grabs it’’s value and returns ’’ it in the format we desire. Public Function RetrieveUserName() As String ’’ A const to specify the max length of the user name. Const MaxLen = 50 ’’ Dim some variables to store the info. ’’ A string variable to hold the user name. This variable ’’ must be buffered in order for the function to work. Dim strName As String ’’ Used to contain the length of the name retrieved. Dim lngRetVal As Long ’’ Buffer the string with spaces. strName = Space$(MaxLen) ’’ Get the user name and assign it to strName; ’’ lngRetVal will hold the length of the user name. lngRetVal = GetUserName(strName, MaxLen) ’’ Now we must trim the remaining buffering spaces. strName = Trim$(strName) ’’ Because GetUserName returns a value with a trailing ’’ null termination character, we must remove that ’’ character. strName = Left$(strName, Len(strName) - 1) RetrieveUserName = strName End Function ’’ Now from whatever event we want we can call the procedure ’’ we just wrote to get the user name and assign it to a ’’ string variable. In this example we will call it from ’’ the click event of a command button named Command1. Private Sub Command1_Click() MsgBox RetrieveUserName End Sub Question When someone talks about an object’’s "Interface", what do they mean? ________________________________________ Answer An interface is nothing more than a defined set of public methods and properties (which are really methods, also) that are supported by an object. More than one type of object can support the same interface (for example, TextBoxes and ComboBoxes are both Controls) and an object can support more than one interface (a TextBox is both a TextBox and a Control). Interfaces serve as a contract between the creator of an object and the user of that object. Any object which supports an interface is required to provide each and every property and method that makes up that interface. Question What does the term "Inheritance" mean? ________________________________________ Answer Inheritance, along with encapsulation and polymorphism, is one of the three pillars of object-oriented theory. Inheritance refers to the concept of deriving new objects from existing ones. This creates "is a type of" relationships between the object. Generally this works along the lines of specific object A is a type of general object B (ie. object "Poodle" is a type of "Dog" object). This classifying of objects into base types and sub types is also referred to as abstraction. Inheritance can also take on different meanings. There is implementation inheritance (sometimes called "true" inheritance), where a derived object inherits the behavior (code) of its parent(s). The derived object may use this behavior or in some cases may define its own behavior for selected methods. Interface inheritance, on the other hand, involves a derived object sharing the same interface as its parent. With interface inheritance, the derived class is responsible for providing its own implementation for each inherited method. Question Why should I use property procedures instead of public variables in classes? ________________________________________ Answer Property procedures represent control; always use them instead of public variables. Using public variables in a class means giving up the ability to validate changes to the class’’s data. Using property procedures is also the only way to get Read-Only or Write-Only properties Is Visual Basic an Object-Oriented Language? ________________________________________ Question I’’ve seen people arguing over whether Visual Basic is an object-oriented language. What’’s the answer (and why)? ________________________________________ Answer This question is probably more religious than technical in nature (ie. there’’s no way to answer it without provoking someone). While it offers encapsulation and polymorphism, its lack of implementation inheritance makes the answer ’’No’’ if you adhere to the strictest definition (VB only offers interface inheritance). Visual Basic in its current form (version 6.0) is more of a component-based language. Its object technology is closely bound to the Component Object Model (COM). The version known as VB.Net, however, will meet all of the requirements to be an object- oriented language. Question How do I open the default web browser from a VB program? ________________________________________ Answer Use the ShellExecute API function, and pass it a URL. Example: ’’************************************************* ******** ’’in form module Const SW_SHOWDEFAULT = 10 Private Declare Function ShellExecute Lib "shell32.dll" _ Alias "ShellExecuteA" (ByVal hWnd As Long, _ ByVal lpOperation As String, ByVal lpFile As String, _ ByVal lpParameters As String, _ ByVal lpDirectory As String, ByVal nShowCmd As Long) _ As Long ’’within form (e.g., click event for command or menu) dim lAns as long lAns = ShellExecute(me.Hwnd, "open", _ "http://www.yahoo.com", vbNullString, _ vbNullString, SW_SHOWDEFAULT) Question Just what *is* a dll file? Are they files I create.. The compiler creates..etc? ________________________________________ Answer A dynamic link library (DLL) is a self-contained program or set of small programs, that can be called when needed by other applications running on the computer. The DLL is not compiled within the standard applications (EXEs) to conserve memory, cons erve drive space and to make the specific code within the DLL available to any number of applications. A good example is the VB runtime files. A single copy of each file is all that is needed on the hard drive, yet you can have any number of VB apps installed and they will all access the same set of runtime files. This is much better than compiling the files within each and every VB app. Yes, you can write your own DLL files. It is the compiler that creates or *builds* the DLL.QuestionDo ActiveX DLLs made in VB still need the VB runtimes onthemachine?________________________________________AnswerIn a word, Yes.Visual Basic does not support what is known as "StaticLinking". What that means is that all componets, controls,and applications developed with Visual Basic, also requierthe Visual Basic Runtime libraries.QuestionWhat is a circular reference? Why is it bad?________________________________________AnswerConsider two objects, A and B. A holds a reference to B,and B holds a reference to A. A only releases itsreference to B when A terminates. B only releases itsreference to A when B terminates. Since neither A nor Bwill terminate until all active references to them arereleased, A and B are now immortal (which might sound cool,but is really a ''bad thing'').Circular references should be avoided whenever possible,but in some designs they can be unavoidable. For thosecases, there are various methods for "breaking" circularreferences. One technique is to require the client tomanually clear them (eg. Set A.BReference = Nothing or calla method which releases the reference). Another techniqueis to use unsupported functions (ObjPtr, etc.) to get a non-binding reference to the object. Yet another method is touse a proxy object to dynamically obtain a reference whichis held only for the duration of the callQuestionWhat is meant by "Early Binding" and "Late Binding"? Whichis better?________________________________________AnswerEarly binding and late binding refer to the method used tobind an interface''s properties and methods to an objectreference (variable). Early binding uses type libraryinformation at design time to reference procedures, whilelate binding handles this at run time. Late bindinghandles this by interrogating the reference before eachcall to insure that it supports a particular method. Sinceevery call to a late bound object actually requires twocalls ("Do you do this?" followed by "Okay, do it then"),late binding is much less efficient than early binding.Except where early binding is not supported (ASP,scripting, etc.), late binding should only be used in veryspecial cases.It is a common misconception that any code using theCreateObject function instead of Set = New is using latebinding. This is not the case. The type declaration ofthe object variable determines whether it is late or earlybound, as in the following:Dim A As FooDim B As FooDim C As ObjectDim D As ObjectSet A = New Foo ''Early BoundSet B = CreateObject("FooLib.Foo") ''Early BoundSet C = CreateObject("FooLib.Foo") ''Late BoundSet D = New Foo ''Late BoundQuestionI have been reading on the topic callin win32 APIs, but asI think its a very complex topic I hope anyone can help mesort it out a little more when answering my question:In what kind of circumstances do you actually haveuse accessing WIN32 API?________________________________________AnswerThere are approximately 15,000 functions included in theWIN32 API. It''s a ''collection'' of functions that make upthe ''guts'' of how Windows works.Every application uses these functions to ''be'' a Windowsapplication. In VB we are just shielded from most of itbecause they wrote a bunch of ''wrapper'' functions over theAPI''s for us.Sometimes however they didn''t give us all the functionalitywe need and we will have to use a specific API functionourselves to overcome this limitation. There are a numberof areas where we can do this. Actually just aboutanything and anywhere.However below you will find some quick examples of ''why'' wewould use the API directly. As far as the AddressOfoperator, this is because some API functions requirea ''callback'' function. This is a routine that the API willcall when it has finished it''s processing and wants to letyou know it''s ''your turn'' again.Some examples...* Putting icons in the System Tray* Getting / Setting text to other applications (commonlycalled "Screen-Scrapping")* Creating high precision timer functions (vb''s are verylimited)* Subclassing a form or window (<--too much here toexplain shortly)* Making a specific window always being on top of otherwindowsQuestionWhy do so many example programs not use the DLL namedirectly without an alias? Surely the DLL names do notcommonly clash with existing names.________________________________________AnswerThere are a lot of reasons to use aliases. For instance, theSendMessage API. You need to change the data types you aresending to the API, so you need to have multipledeclarations of the same API.There are many structures (UDTs) which are bigger or smallerin NT than they are in Win9x. So, again, you need to changewhat UDT you are pointing at depending on the OS. Since youcan''''t do this on the fly, you need to write to differentdeclares.Also, there are a lot of APIs that need to differentiatebetween whether you are sending it a unicode or an ansistring.QuestionWhat is a hWnd and what can it be used for?Code examples for different kinds of usage are welcome.________________________________________AnswerAn hWnd is a Handle to a Window if you will. A handle is along integer generated by the operating system so it cankeep track of the all the objects (a form, a command buttonetc.)You can''t set a hwnd at design or runtime, and the value ofthe handle changes each time the form is opened. Handlesare used when you make calls to API functions, the functionneeds to know the handle of the window, plus otherarguements depending on the whatthe API does.The GetWindowsText API frx:Declare Function GetWindowText Lib "user32" alias _"GetWindowTextA" (byval Hwnd as long, byval lpstring as _string, byval cch as long) as LongAssuming the object in question is a form, passing the hwndof the form to the api will cause a search to performed inwindows internal data structures looking for that handle,and then return what text is in the forms title baror caption.QuestionIs there an event that fires when an application loses thefocus (Deactivate fires when a form loses focus to anotherform in the same app, but not when I bring anotherapplication to the front).________________________________________AnswerNo event fires ... but the active window receives theWM_ACTIVATEAPP message.QuestionHow can I close another program?________________________________________AnswerYou have to use the API - here''s a code example, you''llneed to create a CommandButton called "Command1" on a formand paste this code in. You''ll need to modify the functioncall under the Command1_Click event to reflect the WindowCaption \ Class you are trying to close.Option Explicit''This API is for the SendMessage function call - basicallysends a message to the specified hWndPrivate Declare Function SendMessage Lib "user32"Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg AsLong, ByVal wParam As Long, ByVal lParam As Any) As Long''This API is for the FindWindow call - is used to Find awindow based ona given Window class name or Window title(caption)Private Declare Function FindWindow Lib "user32"Alias "FindWindowA" (ByVal lpClassName As String, ByVallpWindowName As String) As Long''This API will return a formatted string for a give DLLerrorPrivate Declare Function FormatMessage Lib "kernel32"Alias "FormatMessageA" (ByVal dwFlags As Long, ByVallpSource As Long, ByVal dwMessageId As Long, ByValdwLanguageId As Long, ByVal lpBuffer As String, ByVal nSizeAs Long, Arguments As Any) As Long''const required for FormatMessagePrivate Const FORMAT_MESSAGE_FROM_SYSTEM = &H1000''Our string buffer lengthPrivate Const BUFFER_LENGTH As Long = 255''This const is used with the SendMessage callPrivate Const WM_CLOSE As Long = &H10''Our custom consts (for readability)Private Const NO_ERROR As Long = 0Private Const BYVAL_NULL As Long = 0&Private Sub Command1_Click()''Function call''in this case we are looking for a window with thecaption "KillMe"''change it to suit your needsKillWindow , "KillMe"End SubPublic Function KillWindow(Optional WindowClass As String =vbNullString, Optional WindowTitle As String = vbNullString)''************************************************* ***************''* Function Name:KillWindow *''* Author: Lewis Cornick(co**@developerexchange.co.uk) *''* Description: Use to find and close a specificWindow. *''* Date Created: 18th January2001 *''* DateModified: *''*Mods:*''************************************************* ***************Dim lhWnd As LongDim lRes As LongDim lErrorNumber As LongDim sErrorDescription As String * BUFFER_LENGTHDim lFlags As LongOn Error GoTo Err_Handler''Ensure our strings are null terminatedWindowClass = WindowClass & vbNullStringWindowTitle = WindowTitle & vbNullString''In this case we are going to try and find the theWindowHandle,''if we already knew the hWnd we could just pass thatstraight to''the SendMessage call.''Call the FindWindow API, this will return us a validWindowHandle,''If its not a valid window (window isn''t found)FindWindow will return''0 and Err.LastDLLError will be populated with anWindows error number''(see the FormatMessage call)lhWnd = FindWindow(WindowClass, WindowTitle)''We assume we have a valid WindowHandle, now its timeto send the''WM_CLOSE message to tell the window \ app to close.lRes = SendMessage(lhWnd, WM_CLOSE, BYVAL_NULL,BYVAL_NULL)Err_Handler:''Our Error Handler.''Check the standard windows error number *and* the DLLError to ensure''that neither the FindWindow or the SendMessage callfailed.If Err.Number <NO_ERROR Or Err.LastDllError <>NO_ERROR Then''Something failed - need to decide what it wasIf Err.Number <NO_ERROR Then''Must be a straight VB errorlErrorNumber = Err.NumbersErrorDescription = Err.DescriptionElse''An API failed - probably FindWindow due to theWindow not being found.lErrorNumber = Err.LastDllError''This API will take the Error number generatedfrom the API call and''Format it into a English string for us toreport back to the user.lRes = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, BYVAL_NULL, lErrorNumber,BYVAL_NULL, sErrorDescription, BUFFER_LENGTH, BYVAL_NULL)End If''Raise the error up to whoever called the function.Err.Raise lErrorNumber, "KillWindow",sErrorDescriptionEnd IfEnd FunctionQuestionHow do I make Windows shut down or restart?________________________________________AnswerThe API function ExitWindowsEx causes Windows to shut downor restart. It is declared:Private Declare Function ExitWindowsEx Lib "user32"Alias "ExitWindowsEx" (ByVal uFlags As Long, ByValdwReserved As Long) As LongThe following constants may be passed as the firstparameter:Private Const EWX_LOGOFF = 0Private Const EWX_REBOOT = 2Private Const EWX_SHUTDOWN = 1Their use is self-explanatory. Always pass 0& as thesecond parameter.ExitWindowsEx may not work properly in NT or Windows 2000if the server or workstation is locked. If you encountersuch difficulties, search the a fix is available from theMicrosoft KB. Search it for "ExitWindowsEx".QuestionHow do I send keystrokes to another application?________________________________________AnswerFirst you have to make the App active, with AppActivate,then you can send keys using SendKeys, both are welldocumented in the MSDN libary.Here is an example.Dim dblReturnValue As Double'' The Apps HandledblReturnValue = Shell("Notepad.EXE", 1)''Shell Notepad, and return the Handle to the appAppActivate dblReturnValue''Activate the app pointed to by the handleSendKeys "VB-FAQ! Thanks for Visiting!"''Send some keys to the appSendKeys "%{F4}" '' Quit''Close the app using % = ALT + {F4} key(F4)QuestionWhy should I use ADO as opposed to DAO?________________________________________AnswerDAO has not been supported by microsoft for a long timenow. ADO is Microsoft''s data access technology for all thecurrent applications.The only use for dao is internally within an older versionof access which doesn''t have the currentproject.connectionproperty to get the ADO connection from.All external access to an ACCESS database should be donethrought the oledb drivers with ADOQuestionWhy should I use a stored procedure?________________________________________AnswerMany RDBMS''s (Relational DataBase Management System''s)support stored procedures SQLServer, Oracle, etc. Let''slook at what a Stored Procedure ''is'' before we answer whyyou should use them.A stored procedure is essentially a routine you create thatwill execute an SQL statement. You can define parametersfor the Stored Procedure to take, and most RDBMS''s allowthem to have a return value as well. You can create storedprocedures to handle your UPDATEs, INSERTs, SELECTs, andDELETEs...and even a couple things that don''t have much todo with any of those, and some that do all of those at thesame time. It''s up to what you need it to perform.There are four major reasons why using them canslightly/greatly beneficial.1. They can dramatically increase security.If you set up a series of Stored Procedures to handle allof your interaction to the data then this means that youcan remove all the user rights on all of your tables andsuch. For example; say I create a stored procedure forinserting a new employee. I design that stored procedureso that it expects all the required parameters to insertinto the EMPLOYEES table as well as some data to insertinto related tables. I then write the stored procedure todo exactly that. I can remove everyone''s rights to theactual EMPLOYEES table and require them to only do INSERTSvia the stored procedure. I have effectively forced themto always insert data my way.2. They can assist you in centralizing your code.If I ever need to change the structure of that EMPLOYEEStable I don''t have to worry about any applications crashingif when they try to insert something new. Since allinteraction is via that stored procedure I just have tomake the updates in that one stored procedures code andnowhere else.3. They are executed on the Server''s machine.Because they actually reside on the server''s machine, theywill use the process resources there as well. Generallyyour Database Server will be much more ''beefy'' as far asprocessor and memory resources go than your clientsmachines.4. Better than that. (They are precompiled)Since the stored procedure is stored into the RDBMS, theRDBMS can actually look at how the SQL Statement isprocessed and ''precompile'' the statement. This means thatsince the database can convert your stored procedure intobinary code and execute it as one command rather than parsethe SQL statement through an interpreter as if it wastext. Execution speeds can be vastly improved by thisalone.So to recap, the reasons you might want to consider storedprocedures are 1. Security, 2. Maintenance, 3. Moreabundant resources, 4. Precompiled for speed execution.QuestionHow can I embed a Crystal Report (version 8) into my VBproject?________________________________________AnswerYou''ll have to use the embedded report designer. To make itavailable, go to the Project Menu >Components >>Insertable Objects, and check it off. Now you''ll have anoption in the Add menu (right-click project explorer, oruse the Project menu) named, "Crystal Reports 8...."QuestionHow can I stop and start a SQL Server in Code?________________________________________AnswerUsing the SQLDMO object you can control a SQL Server at themanagment level.ThusDim objSQL as SQlDMO.SQLServerset objSQL = new SQLDMO.SQLServeron error resume nextobjSQL.start strServerName, strUserName, strPasswordif err.number <0 then ''* server is already runningobjSQL.connect strServerName, strUserName, strPasswordobjSQL.shutdown Trueend ifset objSql = nothingQuestionWhat is MSDE? How is it different from MS Access? SQLServer?________________________________________AnswerMSDE (Microsoft Data Engine) is the desktop version of SQLServer. It is essentially the SQL Server database engine,with some limitations: databases are limited to 2gigabytes, MSDE can''t be a publisher for replication, andit is designed for 5 or fewer concurrent users. It doessupport many of the same features as the full version ofSQL Server, most notably, stored procedures.Like SQL Server, MSDE is a true database server. Datarequests are processed on the machine where MSDE resides,as opposed to on the client with Microsoft Accessdatabases. This fact makes MSDE much more suitable thanAccess for solutions with a small number of concurrentusers.QuestionHow can I determine the capacity of drives?________________________________________AnswerThe following was downloaded off the Internet. Apologiesthat the author cannot be credited. The code provides anumber of functions related to drives. Beware of word wrapwhen copying this code.''******************Drives.bas********************* ******''In its present form it runs from Sub Main() and shows the''debug window: no user interface. I did not need, for''instance, total disc space. One could, however, change''Debug.Print to Form1.Print or List1.AddItem and place'' ''DetectDrives'' in Form_activate or a Command Button''and start with the form instead of Sub Main(). Paste''this code into a module. Place a floppy and a CD in''the drives. Either remove form from project or start''from Sub Main(). I have tried to include the most''important comments for easy understanding. Functions''are Private except ''DetectDrives''.''************************************************* ******Private Declare Function GetLogicalDriveStrings _Lib "kernel32" Alias "GetLogicalDriveStringsA" (ByVal _nBufferLength As Long, ByVal lpBuffer As String) As LongPrivate Declare Function GetDriveType Lib "kernel32" _Alias "GetDriveTypeA" (ByVal nDrive As String) As LongPrivate Declare Function GetDiskFreeSpace Lib "kernel32" _Alias "GetDiskFreeSpaceA" (ByVal lpRootPathName As _String, lpSectorsPerCluster As Long, lpBytesPerSector _As Long, lpNumberOfFreeClusters As Long, _lpTotalNumberOfClusters As Long) As LongPrivate Declare Function GetVolumeInformation Lib _"kernel32.dll" Alias "GetVolumeInformationA" (ByVal _lpRootPathName As String, ByVal lpVolumeNameBuffer As _String, ByVal nVolumeNameSize As Integer, _lpVolumeSerialNumber As Long, lpMaximumComponentLength _As Long, lpFileSystemFlags As Long, ByVal _lpFileSystemNameBuffer As String, ByVal _nFileSystemNameSize As Long) As LongPublic Const DRIVE_REMOVABLE = 2Public Const DRIVE_FIXED = 3Public Const DRIVE_REMOTE = 4Public Const DRIVE_CDROM = 5Public Const DRIVE_RAMDISK = 6Sub Main()DetectDrivesEnd SubPrivate Function Serial(dPath As String) As LongDim N As LongDim lRet As LongDim fBuf As StringDim sBuf As StringfBuf = Space(255)sBuf = Space(255)lRet = GetVolumeInformation(dPath, fBuf, Len(fBuf), _N, 0, 0, sBuf, Len(sBuf))Serial = NEnd FunctionPrivate Function Range(ByVal nBytes As Long) As StringConst KB As Double = 1024Const MB As Double = 1024 * KBConst GB As Double = 1024 * MBIf nBytes < KB ThenRange = Format(nBytes) & " bytes"ElseIf nBytes < MB ThenRange = Format(nBytes / KB, "0.00") & " KB"ElseIf nBytes < GB ThenRange = Format(nBytes / MB, "0.00") & " MB"ElseRange = Format(nBytes / GB, "0.00") & " GB"End IfEnd FunctionPrivate Function FreeSpace(ByVal DrvPath As String) AsStringDim Sectors As Long ''per clusterDim Bytes As Long ''per sectorDim FreeClusters As LongDim Clusters As Long ''totalIf GetDiskFreeSpace(DrvPath, Sectors, Bytes,FreeClusters, Clusters) ThenFreeSpace = FreeClusters * Sectors * BytesElseFreeSpace = 0End IfFreeSpace = Range(FreeSpace) ''converts to bytes or MBEnd FunctionPublic Function DetectDrives()Dim i As IntegerDim drvStr As StringDim AllDrvs As StringDim lRet As LongDim dType As Integer ''see constants in generaldeclarationsAllDrvs = Space(255)lRet = GetLogicalDriveStrings(Len(AllDrvs), AllDrvs)For i = 1 To lRet Step 4 ''AllDrvs contains paths Withspaces in betweendrvStr = UCase(Mid(AllDrvs, i, 3)) '' like: A:\ C:\D:\dType = GetDriveType(drvStr) '' hence: Step 4Select Case dType ''for each type shows Path,Serial#, and Freespace.Case 2Debug.Print drvStr & " Floppy #" & Serial _(drvStr) & " Freespace " & FreeSpace(drvStr)Case 3Debug.Print drvStr & " Hard Disk #" & Serial _(drvStr) & " Freespace " & FreeSpace(drvStr)Case 4Debug.Print drvStr & " External Drive #" & _Serial(drvStr) & " Freespace " & FreeSpace(drvStr)Case 5Debug.Print drvStr & " CD-Rom #" & Serial _(drvStr) & " Freespace " & FreeSpace(drvStr)Case 6Debug.Print drvStr & " Ram Drive #" & Serial _(drvStr) & " Freespace " & FreeSpace(drvStr)End SelectNext iEnd FunctionQuestionI would like to use a text file to hold very simpleinformation such as integers or doubles. How can i save andretrieve information from a text file into my program andperhaps put it into a variable?________________________________________Answer''Write to the fileOpen "thefile" for Output as 1Print #1, "This is my file."Print #1, 12345Close #1''Append to the fileOpen "thefile" for Append as 1Print #1, "This is another line."Close #1''Read from the fileDim mystring As String, mynumber As IntegerOpen "thefile" for input as 1Input #1, mystringInput #1, mynumberClose #1QuestionHow do I keep my form on top of all other windows?________________________________________AnswerTo keep a form on top of all other windows is a simplematter of making one call the the SetWindowPos API. Belowis a code example:'' The API used to keep a window on top of all other windows.Private Declare Function SetWindowPos Lib "user32" (ByVal _hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As _Long, ByVal y As Long, ByVal cx As Long, ByVal cy As _Long, ByVal wFlags As Long) As Long'' Several constants that are used in conjunction with that'' API. Not all of these will be used to keep a form on top,'' but feel free to play with them.Private Const SWP_FRAMECHANGED = &H20Private Const SWP_DRAWFRAME = SWP_FRAMECHANGEDPrivate Const SWP_HIDEWINDOW = &H80Private Const SWP_NOACTIVATE = &H10Private Const SWP_NOCOPYBITS = &H100Private Const SWP_NOMOVE = &H2Private Const SWP_NOOWNERZORDER = &H200Private Const SWP_NOREDRAW = &H8Private Const SWP_NOREPOSITION = SWP_NOOWNERZORDERPrivate Const SWP_NOSIZE = &H1Private Const SWP_NOZORDER = &H4Private Const SWP_SHOWWINDOW = &H40Private Const HWND_BOTTOM = 1Private Const HWND_TOP = 0Private Const HWND_NOTOPMOST = -2Private Const HWND_TOPMOST = -1'' In the event of your choice you can place the positioning'' code. In this example the code is placed in the form''s'' load event.'' If you want to stop a form from being the topmost window,'' simply replace the HWND_TOPMOST constant with the'' HWND_NOTOPMOST constant.Private Sub Form_Load()'' A long to hold the return value of the SetWindowPos'' API.Dim lngRetVal As Long'' Set the form to be the topmost window.lngRetVal = SetWindowPos(Me.hwnd, HWND_TOPMOST, 0, 0, _0, 0, SWP_NOSIZE Or SWP_NOMOVE)End SubQuestionI have a situation where I need to load a form by its namerather than simply creating an object variable. How can Ido this?________________________________________AnswerThere are definitely some circumstances where one wouldneed to load a form by its name. Not getting into thosecircumstances, here is how it''s accomplished:Public Sub LoadFormByName(ByVal sFormName As String)Dim frm As FormSet frm = Forms.Add(sFormName)frm.ShowEnd SubOf course, adequate error handling should be added to theprocedure to ensure the app doesn''t crash if the formreferenced in sFormName doesn''t exist.QuestionI have a form called MyForm. I''d like to create multipleinstances of this form, but when I do MyForm.Show itcreates a single instance and manipulates that singleinstance. How can I create multiple instances of MyForm?________________________________________AnswerYou need to use form variables to accomplish this. Here isa short sample showing how you might create 3 separate anddistinct instances of a form named MyForm.Public Sub Show3Forms()Dim f1 As MyFormDim f2 As MyFormDim f3 As MyFormSet f1 = New MyFormSet f2 = New MyFormSet f3 = New MyFormf1.Showf2.Showf3.ShowEnd SubQuestionOn a login form, I have a combo box with 2 entries thatwill allow the user to select which DB environment theywish to work in.On start up I want the combo box to have "Production" showas the default selection. I cannot seem to have thishappen. Everytime the form loads the user must click thearrow to make a selection.________________________________________AnswerTry adding this code.If cboEnvironment.ListCount 0 ThencboEnvironment.ListIndex = 0End IfQuestionI''ve been trying and searching and cannot find anyinformation explaining how to disable the "X" in the upperright hand corner in an MDI child form. Any ideas?________________________________________Answer'' *** Begin APIs for removing the close button from thecontrol box.'' Menu item constants.Private Const SC_CLOSE As Long = &HF060&'' SetMenuItemInfo Mask constants.Private Const MIIM_STATE As Long = &H1&Private Const MIIM_ID As Long = &H2&'' SetMenuItemInfo State constants.Private Const MFS_GRAYED As Long = &H3&Private Const MFS_CHECKED As Long = &H8&'' SendMessage constants.Private Const WM_NCACTIVATE As Long = &H86'' User-defined Type to contain menu info.Private Type MENUITEMINFOcbSize As LongfMask As LongfType As LongfState As LongwID As LonghSubMenu As LonghbmpChecked As LonghbmpUnchecked As LongdwItemData As LongdwTypeData As Stringcch As LongEnd Type'' Declarations for retrieving and setting menus and menuinfo.Private Declare Function GetSystemMenu Lib "user32" ( _ByVal hWnd As Long, ByVal bRevert As Long) As LongPrivate Declare Function GetMenuItemInfo Lib "user32" Alias_"GetMenuItemInfoA" (ByVal hMenu As Long, ByVal un AsLong, _ByVal b As Boolean, lpMenuItemInfo As MENUITEMINFO) AsLongPrivate Declare Function SetMenuItemInfo Lib "user32" Alias_"SetMenuItemInfoA" (ByVal hMenu As Long, ByVal un AsLong, _ByVal BOOL As Boolean, lpcMenuItemInfo As MENUITEMINFO)As Long'' A long to contain the handle to the menu we aremanipulating.Private hMenu As Long'' A menuiteminfo type used for passing to API calls.Private MII As MENUITEMINFO'' A constant used for changing the ID of the menu item. Thisis done'' because VB will reset our changes if we leave the IDalone.Const xSC_CLOSE = -10'' This function is used to send messages to windows.Private Declare Function SendMessage Lib "user32" Alias"SendMessageA"(ByVal hWnd As _Long, ByVal wMsg As Long, ByVal wParam As Long, lParam AsString) As Long'' *** End APIs for removing the close button from controlbox.Private Sub Form_Load()'' Disable the close button in the control box.Dim Ret As LongDim lngOldID As Long'' Retrieve the menu item info.hMenu = GetSystemMenu(Me.hWnd, 0)MII.cbSize = Len(MII)MII.dwTypeData = String(80, 0)MII.cch = Len(MII.dwTypeData)MII.fMask = MIIM_STATEMII.wID = SC_CLOSERet = GetMenuItemInfo(hMenu, MII.wID, False, MII)'' Set the state to disabled and greyed.MII.fState = MFS_GRAYED'' Store the old ID.lngOldID = MII.wID'' Change the ID.MII.wID = xSC_CLOSE'' Indicate to the structure that we are changing the IDand the state.MII.fMask = MIIM_ID Or MIIM_STATE'' Set the menu item to the new value.Ret = SetMenuItemInfo(hMenu, lngOldID, False, MII)'' Send the WM_NCACTIVATE message to the form so itupdates the controlbox.Call SendMessage(Me.hWnd, WM_NCACTIVATE, True, 0)End SubQuestionHow do I get the name of the logged on user?________________________________________AnswerOption Explicit'' The first thing to do is to declare the proper API'' function, as follows:Private Declare Function GetUserName Lib "advapi32.dll" _Alias "GetUserNameA" (ByVal lpBuffer As String, nSize _As Long) As Long'' Now we need a function which calls the API we just'' declared and then grabs it''s value and returns'' it in the format we desire.Public Function RetrieveUserName() As String'' A const to specify the max length of the user name.Const MaxLen = 50'' Dim some variables to store the info.'' A string variable to hold the user name. This variable'' must be buffered in order for the function to work.Dim strName As String'' Used to contain the length of the name retrieved.Dim lngRetVal As Long'' Buffer the string with spaces.strName = Space$(MaxLen)'' Get the user name and assign it to strName;'' lngRetVal will hold the length of the user name.lngRetVal = GetUserName(strName, MaxLen)'' Now we must trim the remaining buffering spaces.strName = Trim$(strName)'' Because GetUserName returns a value with a trailing'' null termination character, we must remove that'' character.strName = Left$(strName, Len(strName) - 1)RetrieveUserName = strNameEnd Function'' Now from whatever event we want we can call the procedure'' we just wrote to get the user name and assign it to a'' string variable. In this example we will call it from'' the click event of a command button named Command1.Private Sub Command1_Click()MsgBox RetrieveUserNameEnd SubQuestionWhen someone talks about an object''s "Interface", what dothey mean?________________________________________AnswerAn interface is nothing more than a defined set of publicmethods and properties (which are really methods, also)that are supported by an object. More than one type ofobject can support the same interface (for example,TextBoxes and ComboBoxes are both Controls) and an objectcan support more than one interface (a TextBox is both aTextBox and a Control).Interfaces serve as a contract between the creator of anobject and the user of that object. Any object whichsupports an interface is required to provide each and everyproperty and method that makes up that interface.QuestionWhat does the term "Inheritance" mean?________________________________________AnswerInheritance, along with encapsulation and polymorphism, isone of the three pillars of object-oriented theory.Inheritance refers to the concept of deriving new objectsfrom existing ones. This creates "is a type of"relationships between the object. Generally this worksalong the lines of specific object A is a type of generalobject B (ie. object "Poodle" is a type of "Dog" object).This classifying of objects into base types and sub typesis also referred to as abstraction.Inheritance can also take on different meanings. There isimplementation inheritance (sometimes called "true"inheritance), where a derived object inherits the behavior(code) of its parent(s). The derived object may use thisbehavior or in some cases may define its own behavior forselected methods. Interface inheritance, on the otherhand, involves a derived object sharing the same interfaceas its parent. With interface inheritance, the derivedclass is responsible for providing its own implementationfor each inherited method.QuestionWhy should I use property procedures instead of publicvariables in classes?________________________________________AnswerProperty procedures represent control; always use theminstead of public variables. Using public variables in aclass means giving up the ability to validate changes tothe class''s data. Using property procedures is also theonly way to get Read-Only or Write-Only propertiesIs Visual Basic an Object-Oriented Language?________________________________________QuestionI''ve seen people arguing over whether Visual Basic is anobject-oriented language. What''s the answer (and why)?________________________________________AnswerThis question is probably more religious than technical innature (ie. there''s no way to answer it without provokingsomeone). While it offers encapsulation and polymorphism,its lack of implementation inheritance makes theanswer ''No'' if you adhere to the strictest definition (VBonly offers interface inheritance). Visual Basic in itscurrent form (version 6.0) is more of a component-basedlanguage. Its object technology is closely bound to theComponent Object Model (COM). The version known as VB.Net,however, will meet all of the requirements to be an object-oriented language.QuestionHow do I open the default web browser from a VB program?________________________________________AnswerUse the ShellExecute API function, and pass it a URL.Example:''************************************************* ********''in form moduleConst SW_SHOWDEFAULT = 10Private Declare Function ShellExecute Lib "shell32.dll" _Alias "ShellExecuteA" (ByVal hWnd As Long, _ByVal lpOperation As String, ByVal lpFile As String, _ByVal lpParameters As String, _ByVal lpDirectory As String, ByVal nShowCmd As Long) _As Long''within form (e.g., click event for command or menu)dim lAns as longlAns = ShellExecute(me.Hwnd, "open", _"http://www.yahoo.com", vbNullString, _vbNullString, SW_SHOWDEFAULT)QuestionJust what *is* a dll file?Are they files I create.. The compiler creates..etc?________________________________________AnswerA dynamic link library (DLL) is a self-contained program orset of small programs, that can be called when neededby other applications running on the computer.The DLL is not compiled within the standard applications(EXEs) to conserve memory, conserve drive space and tomake the specific code within the DLL available to anynumber of applications.A good example is the VB runtime files. A single copy ofeach file is all that is needed on the hard drive, yetyou can have any number of VB apps installed and they willall access the same set of runtime files. This is muchbetter than compiling the files within each and everyVB app.Yes, you can write your own DLL files. It is the compilerthat creates or *builds* the DLL.推荐答案(MaxLen) ’’ Get the user name and assign it to strName; ’’ lngRetVal will hold the length of the user name. lngRetVal = GetUserName(strName, MaxLen) ’’ Now we must trim the remaining buffering spaces. strName = Trim(MaxLen)'' Get the user name and assign it to strName;'' lngRetVal will hold the length of the user name.lngRetVal = GetUserName(strName, MaxLen)'' Now we must trim the remaining buffering spaces.strName = Trim(strName) ’’ Because GetUserName returns a value with a trailing ’’ null termination character, we must remove that ’’ character. strName = Left(strName)'' Because GetUserName returns a value with a trailing'' null termination character, we must remove that'' character.strName = Left(strName, Len(strName) - 1) RetrieveUserName = strName End Function ’’ Now from whatever event we want we can call the procedure ’’ we just wrote to get the user name and assign it to a ’’ string variable. In this example we will call it from ’’ the click event of a command button named Command1. Private Sub Command1_Click() MsgBox RetrieveUserName End Sub Question When someone talks about an object’’s "Interface", what do they mean? ________________________________________ Answer An interface is nothing more than a defined set of public methods and properties (which are really methods, also) that are supported by an object. More than one type of object can support the same interface (for example, TextBoxes and ComboBoxes are both Controls) and an object can support more than one interface (a TextBox is both a TextBox and a Control). Interfaces serve as a contract between the creator of an object and the user of that object. Any object which supports an interface is required to provide each and every property and method that makes up that interface. Question What does the term "Inheritance" mean? ________________________________________ Answer Inheritance, along with encapsulation and polymorphism, is one of the three pillars of object-oriented theory. Inheritance refers to the concept of deriving new objects from existing ones. This creates "is a type of" relationships between the object. Generally this works along the lines of specific object A is a type of general object B (ie. object "Poodle" is a type of "Dog" object). This classifying of objects into base types and sub types is also referred to as abstraction. Inheritance can also take on different meanings. There is implementation inheritance (sometimes called "true" inheritance), where a derived object inherits the behavior (code) of its parent(s). The derived object may use this behavior or in some cases may define its own behavior for selected methods. Interface inheritance, on the other hand, involves a derived object sharing the same interface as its parent. With interface inheritance, the derived class is responsible for providing its own implementation for each inherited method. Question Why should I use property procedures instead of public variables in classes? ________________________________________ Answer Property procedures represent control; always use them instead of public variables. Using public variables in a class means giving up the ability to validate changes to the class’’s data. Using property procedures is also the only way to get Read-Only or Write-Only properties Is Visual Basic an Object-Oriented Language? ________________________________________ Question I’’ve seen people arguing over whether Visual Basic is an object-oriented language. What’’s the answer (and why)? ________________________________________ Answer This question is probably more religious than technical in nature (ie. there’’s no way to answer it without provoking someone). While it offers encapsulation and polymorphism, its lack of implementation inheritance makes the answer ’’No’’ if you adhere to the strictest definition (VB only offers interface inheritance). Visual Basic in its current form (version 6.0) is more of a component-based language. Its object technology is closely bound to the Component Object Model (COM). The version known as VB.Net, however, will meet all of the requirements to be an object- oriented language. Question How do I open the default web browser from a VB program? ________________________________________ Answer Use the ShellExecute API function, and pass it a URL. Example: ’’************************************************* ******** ’’in form module Const SW_SHOWDEFAULT = 10 Private Declare Function ShellExecute Lib "shell32.dll" _ Alias "ShellExecuteA" (ByVal hWnd As Long, _ ByVal lpOperation As String, ByVal lpFile As String, _ ByVal lpParameters As String, _ ByVal lpDirectory As String, ByVal nShowCmd As Long) _ As Long ’’within form (e.g., click event for command or menu) dim lAns as long lAns = ShellExecute(me.Hwnd, "open", _ "http://www.yahoo.com", vbNullString, _ vbNullString, SW_SHOWDEFAULT) Question Just what *is* a dll file? Are they files I create.. The compiler creates..etc? ________________________________________ Answer A dynamic link library (DLL) is a self-contained program or set of small programs, that can be called when needed by other applications running on the computer. The DLL is not compiled within the standard applications (EXEs) to conserve memory, cons erve drive space and to make the specific code within the DLL available to any number of applications. A good example is the VB runtime files. A single copy of each file is all that is needed on the hard drive, yet you can have any number of VB apps installed and they will all access the same set of runtime files. This is much better than compiling the files within each and every VB app. Yes, you can write your own DLL files. It is the compiler that creates or *builds* the DLL.(strName, Len(strName) - 1)RetrieveUserName = strNameEnd Function'' Now from whatever event we want we can call the procedure'' we just wrote to get the user name and assign it to a'' string variable. In this example we will call it from'' the click event of a command button named Command1.Private Sub Command1_Click()MsgBox RetrieveUserNameEnd SubQuestionWhen someone talks about an object''s "Interface", what dothey mean?________________________________________AnswerAn interface is nothing more than a defined set of publicmethods and properties (which are really methods, also)that are supported by an object. More than one type ofobject can support the same interface (for example,TextBoxes and ComboBoxes are both Controls) and an objectcan support more than one interface (a TextBox is both aTextBox and a Control).Interfaces serve as a contract between the creator of anobject and the user of that object. Any object whichsupports an interface is required to provide each and everyproperty and method that makes up that interface.QuestionWhat does the term "Inheritance" mean?________________________________________AnswerInheritance, along with encapsulation and polymorphism, isone of the three pillars of object-oriented theory.Inheritance refers to the concept of deriving new objectsfrom existing ones. This creates "is a type of"relationships between the object. Generally this worksalong the lines of specific object A is a type of generalobject B (ie. object "Poodle" is a type of "Dog" object).This classifying of objects into base types and sub typesis also referred to as abstraction.Inheritance can also take on different meanings. There isimplementation inheritance (sometimes called "true"inheritance), where a derived object inherits the behavior(code) of its parent(s). The derived object may use thisbehavior or in some cases may define its own behavior forselected methods. Interface inheritance, on the otherhand, involves a derived object sharing the same interfaceas its parent. With interface inheritance, the derivedclass is responsible for providing its own implementationfor each inherited method.QuestionWhy should I use property procedures instead of publicvariables in classes?________________________________________AnswerProperty procedures represent control; always use theminstead of public variables. Using public variables in aclass means giving up the ability to validate changes tothe class''s data. Using property procedures is also theonly way to get Read-Only or Write-Only propertiesIs Visual Basic an Object-Oriented Language?________________________________________QuestionI''ve seen people arguing over whether Visual Basic is anobject-oriented language. What''s the answer (and why)?________________________________________AnswerThis question is probably more religious than technical innature (ie. there''s no way to answer it without provokingsomeone). While it offers encapsulation and polymorphism,its lack of implementation inheritance makes theanswer ''No'' if you adhere to the strictest definition (VBonly offers interface inheritance). Visual Basic in itscurrent form (version 6.0) is more of a component-basedlanguage. Its object technology is closely bound to theComponent Object Model (COM). The version known as VB.Net,however, will meet all of the requirements to be an object-oriented language.QuestionHow do I open the default web browser from a VB program?________________________________________AnswerUse the ShellExecute API function, and pass it a URL.Example:''************************************************* ********''in form moduleConst SW_SHOWDEFAULT = 10Private Declare Function ShellExecute Lib "shell32.dll" _Alias "ShellExecuteA" (ByVal hWnd As Long, _ByVal lpOperation As String, ByVal lpFile As String, _ByVal lpParameters As String, _ByVal lpDirectory As String, ByVal nShowCmd As Long) _As Long''within form (e.g., click event for command or menu)dim lAns as longlAns = ShellExecute(me.Hwnd, "open", _"http://www.yahoo.com", vbNullString, _vbNullString, SW_SHOWDEFAULT)QuestionJust what *is* a dll file?Are they files I create.. The compiler creates..etc?________________________________________AnswerA dynamic link library (DLL) is a self-contained program orset of small programs, that can be called when neededby other applications running on the computer.The DLL is not compiled within the standard applications(EXEs) to conserve memory, conserve drive space and tomake the specific code within the DLL available to anynumber of applications.A good example is the VB runtime files. A single copy ofeach file is all that is needed on the hard drive, yetyou can have any number of VB apps installed and they willall access the same set of runtime files. This is muchbetter than compiling the files within each and everyVB app.Yes, you can write your own DLL files. It is the compilerthat creates or *builds* the DLL. 这篇关于VB FAQs(面试问题)很多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!