Visual Basic For Windows (VB/Win)

Frequently asked Questions & Answers
Section IX - B
Part 3

Last-modified: 22-Aug-95


[Preface] [General VB] [Common VB Questions] [Advanced VB Questions] [Calling the Win. API & DLL's] [VB/Win & Databases] [Distributing Apps] [General Tips] [VB for Apps (VBA)]

The following symbols indicates new & updated topics:

Hope this makes it easier for Our Regular Readers ;-)


TABLE OF CONTENTS:

C. COMMON VISUAL BASIC PROGRAMMING QUESTIONS

C. COMMON VISUAL BASIC PROGRAMMING QUESTIONS


1. What's the difference between MODAL and MODELESS forms? [++]

MODAL forms are forms which require user input before any other actions can be taken place. In other words, a modal form has exclusive focus in that application until it is dismissed. When showing a modal form, the controls outside this modal form will not take user interaction until the form is closed. The internal MsgBox and InputBox forms are examples of modal forms. To show a form modally, use the syntax:
MyForm.SHOW 1
MODELESS forms are those which are shown but do not require immediate user input. MDI child forms are always modeless. To show a form modeless, use the syntax:
MyForm.SHOW
(Thanks to John M. Calvert (calvertj@magi.com) for correcting a slightly embarrassing mistake in previous versions of this topic)

[Top of Page][Table of Contents][Top of FAQ]


2. When/Why should I use Option Explicit?

Option Explicit forces you to declare all variables before using them. Opinions vary greatly on this subject. The main reason to use the OPTION EXPLICIT statement at the top of all modules is to minimize the amount of bugs introduced into your code by misspelling a variable name. Most variants of BASIC (including VB) have the capability to create variables 'on the fly' (without any declarations). This capability can be a double edged sword.

At the minimum, some suggest using the DEFINT A-Z statement in leu of OPTION EXPLICIT. This statement will cause any variables which are created on the fly to be created as integers as opposed to variant (VB 3.0) or single precision (VB 1.0 and 2.0). (Integers take up less memory).

The OPTION EXPLICIT statement causes VB to 'disable' its ability to create variables on the fly. Thus, all variables must be declared using a DIM or REDIM statement. All variables not declared will cause an error when the OPTION EXPLICIT statement is used. This will eliminate bugs caused by a misspelled variable. The option works module-wide, so you can have some modules with nd some without ths option in your project.

[Top of Page][Table of Contents][Top of FAQ]


3. Why does everybody say I should save in TEXT not BINARY?

Actually, saving in binary mode is a bit faster, so why do we recommend you to save in text? If you save the source and the project as text, it becomes ASCII (or really, ANSI) code that you can edit with any text editor or (if you are careful when you save) word processor. If you save in binary, only the VB development environment, current or later versions, will understand the code. The Setup Wizard can not scan binary projects. Also, source documenters and other programming tools usually require text mode. If you use text, you can use a simple text editor (ie. notepad) to cut and paste code from other source/form modules into your current project. Some 'tricks' (like making an array of 1 control into a single non-array control again) is easily done with an editor but not that easy in the environment. If you want to print your project to paper the file|print option in the VB environment is often not good enough; you may want to import the text files into your word processor. And, finally, if something goes wrong (only one byte is changed!) you may be out of luck in binary mode. In text mode you will more easily be able to fix it.

[Top of Page][Table of Contents][Top of FAQ]


4. Is the Variant type slower than using other variable types?

Generally, yes, if we are talking numeric variable types. The Variant type also increases memory overhead. To test the speed difference, try the following piece of code in something like a button_click event and keep the debug window on the screen:
Dim Va As Variant

Dim In As Integer



T1! = Timer

For i% = 1 To 32766

	Va = i%

Next i%

T2! = Timer

Debug.Print "With variant: "; Format$((T2! - T1!),"0.0000")

T1! = Timer

For i% = 1 To 32766

	In = i%

Next i%

T2! = Timer

Debug.Print "With integer:; Format$((T2! - T1!),"0.0000")

This test shows (on our test system) that integers are ~60% faster! However, for strings there where no real difference, or in some instances, variants were faster than strings for routines with heavy conversion usage. For the best result in your application, test your routines directly.

[Top of Page][Table of Contents][Top of FAQ]


5. How do I make a text box not beep but do something else when I hit the Enter key?

Put "something else" in your _KeyPress event, depending on what you really want. This code example makes *nothing* happen, for an extended period of time:
Sub Text1_KeyPress (KeyAscii As Integer)

	If KeyAscii = 13 Then   '13 is Key_Return

	KeyAscii = 0

	End If

End Sub

This might not be a very nice thing to do, since your users usually have some intention when they press Enter. Often they will want to jump to the next control, like the Tab key does.

To have the Enter key emulate the Tab key action, you will need to add the line 'SendKeys "{tab}"' above 'KeyAscii=0' in the example above (Yes, I thought KeyAscii=9 works but it doesn't! Tab is obviously handled by Windows on a lower level).

By the way, you'll also find this in the Microsoft VB Knowledge Base (see KB Q78305 and Q85562).

Note: If MultiLine=True you will *not* want to disable the normal behaviour of the Enter key.

[Top of Page][Table of Contents][Top of FAQ]


6. How do I implement an incremental search in list/dir/combo/file boxes?

This is your lucky day. Dan Champagne (Dan_Champagne@dell.com) made some VB code (no DLLs are necessary!) which easily provides this feature for your applications:
' Code by Dan Champagne

' 4/18/94

' This code can be used to do an incremental search in either a

' list box, dir, combo, or a file box. The following code is set

' for a file box called FILE1. To make it work with a list box, or

' a file box with a different name, change all occurences of FILE1

' with whatever you or VB has named your list, combo, dir, or file box.

' There are two places where you will need to change these. They are

' on the last couple of lines in the KeyPress code.

' Also, thanks to John Tarr for helping debug the code.



'In a .BAS file, add the following:

'searchme$ is a global vaiable that will keep track of what the

'user has typed so far.



Global searchme$



'The following needs to be on one line.



Declare Function SendMessageBystring& Lib "User" ALIAS "SendMessage" (ByVal hWnd%, ByVal wMsg%, ByVal wParam%, ByVal lParam$) 

Global Const WM_USER = &H400

Global Const LB_SELECTSTRING = (WM_USER + 13)

Global Const LB_FINDSTRING = (WM_USER + 16)



'In File1 under keydown, add the following:

'This checks if the user has pressed the up or down arrow.

'If they have, reset searchme$ to "".



If KeyCode = 40 Or KeyCode = 38 Then

	searchme$ = ""

End If



'In File1 under lostfocus, pathchange, patternchange, and click add:

'If the user has done any of the above, reset the searchme$

'string.



searchme$ = ""



'In File1 under keypress add:



Dim result&


Select Case KeyAscii

Case 8     'Backspace

	If searchme$ <> "" Then

		searchme$ = Left$(searchme$, Len(searchme$) - 1)

	Else

		File1.ListIndex = 0

	End If

	KeyAscii = 0

	Exit Sub



Case 27    'Escape

	searchme$ = ""

	KeyAscii = 0

	Exit Sub



Case 13    'Enter

	searchme$ = ""

	KeyAscii = 0

	Exit Sub



Case Asc("a") To Asc("z"), Asc("A") To Asc("Z"), Asc("'"), Asc("."), Asc(" "), Asc("0") To Asc("9")

	searchme$ = searchme$ & Chr$(KeyAscii)

	KeyAscii = 0

End Select



result& = SendMessageBystring(FILE1.hWnd, LB_FINDSTRING,0, searchme$)

If result& = -1 Then

	searchme$ = Left$(searchme$, Len(searchme$) - 1)

Else

	result& = SendMessageBystring(FILE1.hWnd, LB_SELECTSTRING, -1, searchme$)

End If

[Top of Page][Table of Contents][Top of FAQ]


7. How do I get the Tab key to be treated like a normal character?

You must set TabStop = False for ALL controls on the active form. Then you will be able to insert "tab" (chr 9) characters in controls like the text box. If you feel you need the Tab key to behave "normal" (ie. jump to next control) outside this specific control, it is trivial to emulate its functionality in code:
Sub Command1_KeyDown (KeyCode As Integer, Shift As Integer)

	If KeyCode = 9 Then

		If Shift = 0 Then

			Command2.SetFocus 'Tab=Next control

		ElseIf Shift = 1 Then

			Command3.SetFocus 'Shift-Tab=Prev.ctrl.

		End If

	End If

End Sub

...etc.

[Top of Page][Table of Contents][Top of FAQ]


8. How do I make an animated icon for my program?

For an example on how you change the icon for your application as it is displayed when it is minimized, see the example REDTOP in the \samples\picclip directory for VB/Win 3 Pro. This demonstrates a fancy animated icon.

[Top of Page][Table of Contents][Top of FAQ]


9. What is passing by reference?

Arguments are either passed by reference or by value. When they are passed by value, they cannot be changed by the procedure or function they are passed to. They *can* be altered when passed by reference, since passing by reference is just passing the address.

Note that procedures are less strict about variable types when you use BYVAL. If you declare that your Sub takes a Variant, VB takes that seriously and gives a nasty "mismatch error" if you try to pass ie. a string to it. Make it ByVal (at the cost of some speed) and your sub will be more tolerant. Also note the following nasty trap: Arguments are passed by reference unless enclosed by parentheses or declared using the ByVal keyword. [VBWin Language Ref., p. 55]

[Top of Page][Table of Contents][Top of FAQ]


10. I get a "file not found" error on the IIF function when I distribute by program. Uh?

There's a documentation error, since the manual does not tell you that the IIF function requires the file MSAFINX.DLL to be distributed with your application. No, IIF is not financial (I should know, I study finance right now, or at least I should be doing that ;-] ).

[Top of Page][Table of Contents][Top of FAQ]


11. Is there any way to pass a variable to a form apart from using global variables?

The standard workaround is to put an invisible text box (or caption or any other control that suits your use.) on the target form and access it by Form.textbox = "value". Then you can use the Change event of that control to do anything you want in that form. Also, check out the .Tag property which is a "what-you-want" property where you can hook any string you want onto a control. This property can also be accessed from other modules. [Dave Mitton (mitton@dave.enet.dec.com)]

Perhaps a more elegant and flexible way is to implement a stack with similar routines. I've done this for a math project, but this stack was rather complicated and special purpose (and inspired by HP calculators, of whihc I'm a great fan). Jan G.P. Sijm (jan.sijm@intouch.nl) have implemented some routines for general stacks:

Option Explicit                        'Variable declarations required

Dim m_vStack() As Variant              'Stack of variant types



'*  This function will pop a value of a stack of variant

'*  values. The value to be popped (e.g. the variable it

'*  is assigned to) must have one of the basic variable

'*  types that Visual Basic supports. The type of the

'*  return value is determined by the type of the variable

'*  it is assigned to.

'*

'*  Input    : None

'*  Modifies : m_vStack, Stack of variant's

'*  Return   : Value of last pushed variant



Function stkPop () As Variant



	Dim iM As Integer

	iM = UBound(m_vStack)                'Get current stack size

	stkPop = m_vStack(iM)                'Pop value from stack

	iM = iM - 1                          'Decrement number of elements

	ReDim Preserve m_vStack(iM) As Variant



End Function



'*  This function will push a value onto a stack of

'*  variant values. The value to be pushed must have one

'*  of the basic variable types that Visual Basic supports

'*

'*  Input    : vValue, Value to be pushed

'*  Modifies : m_vStack, Stack of variant's



Sub stkPush (ByVal vValue As Variant)

	Dim iM As Integer

	On Error Resume Next                 'Trap for undimensioned array

	iM = UBound(m_vStack)                'Get current array size

	iM = iM + 1                          'Increment number of elements

	ReDim Preserve m_vStack(iM) As Variant

	m_vStack(iM) = vValue                'Push value on stack

End Sub



'This is a short example of how the stack routines can be used in a

'Visual Basic program. This example will push three parameters onto

'the stack. A modal dialog is displayed. The dialog will pop the

'parameters from the stack and set edit controls with the values.



Sub ShowDialog()

	'  Push the parameters for the dialog

	'  onto the stack and display the dialog

	'

	stkPush sName

	stkPush sStreet

	stkPush sCity

	dlgPerson.Show MODAL

End Sub



Form_Load()

	' Pop the parameters of this dialog from the

	' stack in REVERSED ORDER and place the values

	' in the appropriate edit controls.

	'

	dfCity.Text = stkPop()

	dfStreet.Text = stkPop()

	dfName.Text = stkPop()

End Sub

[Top of Page][Table of Contents][Top of FAQ]


12. How should dates be implemented so they work with other language and country formats?

If you use ie. MM/DD/YY format dates in a program, you will get either a runtime-error (ie. month>12) or the wrong date (ie. March 12 instead of December 3) when your program is used in Europe. And vice versa, of course. Even Microsoft's own example programs (like the MAPI sample) make this stupid mistake and fail miserably. Use the Format command to make sure you get the date you want. For example:
strTodaysDate = Format[$](Now, "Short Date")
As a side note, Microsoft has taken much heat on the newsgroup for VB's bad support for internationalization! Just try to make a date literal in source code that works everywhere as a little exercise. Answer elsewhere in this document. No prizes :-)

[Top of Page][Table of Contents][Top of FAQ]


13. Can a VB application be an OLE server?

No. You'll have to use an external DLL/VBX. If you see any examples, please tell the newsgroup.

[Top of Page][Table of Contents][Top of FAQ]


14. How do I dial a phone number without using the MSCOMM VBX?

The MSCOMM VBX that comes with VB/Pro is great for creating communication programs, but it's overkill for dialing a phone number. Try the following code:
PhoneNumber$ = "(123)456-7890"

Open "COM2:" For Output As #1   'or COM1

Print #1, "ATDT" & PhoneNumber$ & Chr$(13)

Close #1

Ian Storrs informed me that he had experienced problems with this when the VB program was run from a network drive. A file named "COM1" was created on the disk! Jeff Rife <jrife@health.org> put in the ":" after COM2 to solve that problem! This trick is probably not a good idea for bigger applications, but it's nice for small personal utilities.

[Top of Page][Table of Contents][Top of FAQ]


15. I have [several] megabytes of memory. Why do I get an "out of memory" error? [++]

This problem and its solution(s) should not be applicable to Windows 95.

Unfortunately, Microsoft has been more famous for memory barriers than anything else. This is a late descendant of the infamous 640K barrier that has been plaguing us for years. Although Windows allows the user to access several megabytes of memory, it uses two limited (64K) memory areas called User Heap and GDI Heap for some specific data structures. Go to the Help|About box in Program Manager to see the percentage of free resources in the *most* exhausted heap. If these areas are exhausted, you are out of luck. VB programs are unfortunately rather greedy on these structures. Windows 4 is supposed to free us from this limitation...

Note that every visible control (ie every button) is a window to Windows. Every new control takes up some bytes in the precious User heap.

Also, there is another way to run out of memory in Windows, not related to VB. Windows requires free Upper Memory Area (UMA, also called Upper Memory Blocks, not to be confused with High RAM, which is the first 64K of extended memory) to do certain tasks. If you use QEMM or DOS 6+ MemMaker and you have many device drivers (network, etc) this area may have been filled up before you launch Windows. You will then be unable to start applications, even though you have plenty of free RAM. The problem can be solved with careful memory setup, but this is far beyond the scope of this FAQ.

On a completely unrelated problem: When you run a program with an outline control with some ATI graphics cards, it may crash with just that error message. (see Knowledge Base [Top of Page][Table of Contents][Top of FAQ]


16. How do I mimic a toggle button? [++]

The only "fix" we know for this problem is to use a picture or image control to mimic the action of a button or button3d control. You need two bitmaps, one for buttonup and one for buttondown (and perhaps one more for inactive state). This is a kluge, we know. Look at the button bar used in the MDINOTE sample program supplied with VB for an example of this.

[Top of Page][Table of Contents][Top of FAQ]


17. How do I get my application on top?

To force a form to the front of the screen, do the following command:
Form1.ZOrder
To make the application *stay* on top, put the Zorder command in a Timer event repeatedly called, say, every 1000 msecs. This makes a "softer" on-top than other methods, and allows the user to make a short peek below the form.

There are two different "Zorder"'s of forms in Windows, both implemented internally as linked lists. One is for "normal" windows, the other for real "topmost" windows (like the Clock application which is distributed with MS Windows). The Zorder command above simply moves your window to the top of the "normal" window stack. To make your window truly topmost, use the SetWindowPos API call like this:

'Make these declares:

Declare Function SetWindowPos Lib "user" (ByVal h%, ByVal hb%, ByVal x%, ByVal y%, ByVal cx%, ByVal cy%, ByVal f%) As Integer 

Global Const SWP_NOMOVE = 2 

Global Const SWP_NOSIZE = 1

Global Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE

Global Const HWND_TOPMOST = -1

Global Const HWND_NOTOPMOST = -2



'To set Form1 as a TopMost form, do the following:



res% = SetWindowPos (Form1.hWnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)



'if res%=0, there is an error



'To turn off topmost (make the form act normal again):



res% = SetWindowPos (Form1.hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, FLAGS)

[Top of Page][Table of Contents][Top of FAQ]


18. Is there a way to break long lines in VB code?

There is unfortunately no line continuation character in VB/Win 3.0. Excel 5 VBA does, however, use Space+Underscore (" _") as a line continuation character, and we hope this will be included in the next version of VB.

There are a few tricks you can use to reduce line length, but unfortunately there is very little to do with DECLARE statements which can get very long.

Print your source in landscape :-/

[Top of Page][Table of Contents][Top of FAQ]


19. How do I remove/change the picture property of a control at design time?

Mark the (bitmap) or (icon) text in the property window and press Del or Backspace. "No!" I hear you cry, "It doesn't work". Well, it does if you first select the object from the combo box at the top of the Properties Window, and then immediately afterwards doubleclick (or paint over) the "(bitmap)" text and press Del. Alternatively, just click on another control, then click back to the first control. Now Del works. Who said "bug"?

If you want to paste your picture directly into the VB program by pressing Ctrl-V when you are editing the picture property, you will have to use a semilar procedure: select the control, select the property, press Ctrl-V. If you try it again without deselecting the control first (or selecting it from the combo box), it doesn't work.

[Top of Page][Table of Contents][Top of FAQ]


20. Is a [foo] VBX/DLL available as shareware/freeware?

Part 4 of the FAQ is Adam Harris' excellent "Shareware Custom Controls List". Please consult this list before you post this question.

The following type of controls are NOT known to be available as sw/pd/fw for Visual Basic, only as commercial toolboxes (If you feel like making any of these for VB and sharing it for a modest fee, you will become very popular!):

If any of these should be available, please tell us.

[Top of Page][Table of Contents][Top of FAQ]


21. How do I make my applications screen-resolution independent?

There are two methods: Either get a custom control that does the job for you, or you write lots of complicated code in the Load and Resize events.

For the first option, check out VideoSoft's $hareware VSVBX.VBX (download VSVBX.ZIP from Cica or mirrors). It has a will of its own, as you will experience, but it's generally better than trying what is described below.

For the brave (or stupid), try to write "screen resolution-smart code" in the form's Load event. If the form is resizable (normally it should be), you'll have to put some magic into the Resize event as well. There are 4 rules of thumb:

  1. Do not trust the form's height and width properties. These measure the entire form, not the client area where your controls are. To see this in action, create a simple applet with the only code being in the resize event which resets a line control from 0,0 to the form's width,height properties. The top left corner is in the client area, the bottom right corner disappears. The API call GetClientRect will return the size of the client area in pixels. You can use the screen object's TwipsPerPixelX and TwipsPerPixelY properties to convert from pixels to twips. If that's not enough, GetWindowRect will return the actual size of the entire form, client and non-client areas combined. GetSystemMetrics will return individual pieces of things like border width/hight, caption height, etc.

  2. Use the TextWidth and TextHeight properties. You can use them off the form if all your controls share the same font, otherwise use them off of the given control. I typically do a TextWidth("X") and TextHeight("X") to get a value which I use as a margin between controls. I grab these values on startup, and multiply it by 2, 1.5, .75, .5, .25 to get varying margin sizes, depending on how close or far apart I want to space things. If your control has an autosize property, you may want to use it, and then calculate the maximum width of a control in a given "column" of controls on your screen and position all of them accordingly.

  3. Try not to resize your controls in the resize event. You will spawn another resize event in the process. Of course, you can use a flag to determine whether the resize event is the original event or the spawned one. Using the load event, and setting the forms borders to fixed minimizes the amount of work you have to do.

  4. Make sure you use a consistant scale. I don't even bother with the scale properties, but instead just convert pixels (from API calls) into twips and be done with it. If you do use scale properties, be sure you convert your numbers correctly. I had no end of difficulty when I failed to convert into twips with one number that was used in a series of calculations to position controls. Also be sure all your controls share the same SCALE -- another nasty problem I had before I gave up on them completely.
[Thanks to our generous anonymous source "D"]

[Top of Page][Table of Contents][Top of FAQ]


22. How do I do Peek and Poke and other low-level stuff? [++]

VB provides no mechanism for this. There are several 3rd party pkgs. which provide this. Also, this often comes up in regards to the comm ports and you can many times do what you want with the mscomm.vbx. [George Tatge (gat@csn.org)]

On The Developer Network Library CD, you'll find the following:

VBASM is a Microsoft(R) Visual Basic(R) dynamic-link library (DLL) that helps Visual Basic programmers accomplish tasks that are difficult or impossible using Visual Basic alone. This sample application includes two programs, SNOOPER and TXTALIGN, that demonstrate the DLL's use. The DLL contains many low-level routines such as access to real and protected mode interrupts, port input/output (I/O), peek/poke, control manipulation, and so on. These routines and their associated functions include:

Control Manipulation:

Pointer and Memory

Byte/Word/Long Manipulation

I/O Access

Interrupts

Others

[Deane Gardner <deaneg@ix.netcom.com> quotes Microsoft.]

There's a shareware package for in/out routines, btw.

[Top of Page][Table of Contents][Top of FAQ]


23. Why doesn't "my string" & Chr$(13) do what I want?

You need to also add a Chr$(10): "my string" & Chr$(13) & Chr$(10) will give you a CR and LF. [George Tatge (gat@csn.org)]

[Top of Page][Table of Contents][Top of FAQ]


24. How do I prevent multiple instances of my program?

In VB 3, the property App.PrevInstance is set to True if an older instance of the program already exist. The following piece of code, stolen from MS KB article Q102480, will activate the old instance and then terminate itself:

Sub Form_Load ()

	If App.PrevInstance Then

		SaveTitle$ = App.Title

		App.Title = "... duplicate instance."      'Pretty, eh?

		Form1.Caption = "... duplicate instance."

		AppActivate SaveTitle$

		SendKeys "% R", True

		End

	End If

End Sub

As Robert Knienider(rknienid@email.tuwien.ac.at) informed me, this piece of code WILL NOT work for non-English versions of MS Windows where the word for "Restore" does not have "R" as the underlined word. Replace the "R" in the SendKeys line above with "{ENTER}" or "~".

Note that you shouldn't prevent multiple instances of your application unless you have a good reason to do so, since this is a very useful feature in MS Windows. Windows will only load the code and dynamic link code *once*, so it (normally) uses much less memory for the later instances than the first.

[Top of Page][Table of Contents][Top of FAQ]


25. How do I implement an accelerator key for a text box?

You want to use a label caption to identify a text box and to act as if it were the text box caption. Example:
&Label1 [text1 ]
How should I do to set the focus to text1, by typing L?

Make sure that the TabIndex property for the text box is 1 greater than the label's TabIndex. Since a label can't have the focus, the focus will go to the next item in the tab order, which would be the text box.

Here's any easy way to set the TabIndex for a busy form. Select the object that should be last in the tab order and then select the TabIndex property. Press 0 (zero), click on the next to last object, press 0, click on the the next object back, press 0, etc. When you're done, all of the TabIndexes will be in order, because VB increments all of the higher TabIndexes when you put in a lower number.

Many thanks to Jonathan Kinnick and Gary Weinfurther that provided the answer on the FIDO net echo VISUAL_BASIC. [Tiago Leal (Tiago.Leal@p25.f1.n283.z2.gds.nl)]

[Top of Page][Table of Contents][Top of FAQ]


26. How do I force a file dialogue box to reread the currect disk?

If you make a simple dialogue box modelled after common dialogue (normally you should *use* the common dialogue VBX!), you will notice that reselecting the diskette drive will not really rescan the disk. Very annoying to change to C:, and to reselect A: just to make it read the directory of a new diskette. To solve this problem, put
drive1.refresh

dir1.refresh

file1.refresh

in the code for the "Rescan" button (or whatever).

[Top of Page][Table of Contents][Top of FAQ]


27. How do I get the number of free bytes on a disk? [++]

As far as I know, there is three possibilities:
  1. SETUPKIT.DLL as mentioned above
  2. Arjen Broeze's VBIO.VBX or something like that, with a lot of options.
  3. Make your own DISKINFO.DLL from the example code in VBKB article Q106553

See Article Q113590 (or Q106553) in Microsoft's VB KnowledgeBase. A short extract follows:

Declare Function DiskSpaceFree Lib "SETUPKIT.DLL" () As Long



Dim free_space& ' Holds number of bytes returned from DiskSpaceFree().

ChDrive "c:"    ' Change to the drive you want to test.

free_space& = DiskSpaceFree()

[Geir Tutturen(itfgt@nlh10.nlh.no)]

[Top of Page][Table of Contents][Top of FAQ]


28. Data Control missing from toolbox when I use VB under NT 3.5. Huh?

Open the VB.INI file and add these lines under the [Visual Basic] heading:
ReportDesign=1

DataAccess=1

[Danny Ames (dames@pic.net)]

[Top of Page][Table of Contents][Top of FAQ]



[Next Section][Previous Section]