If App.PrevInstance Then sMsg = App.EXEName & " already running! " MsgBox sMsg, 4112 EndEnd If This tip is reprinted from the VB Tips & Tricks Volume 1 book.
Category: VB
Win32 API Errors
David McCarter's Essential VB Tips and Techniques
Dan Appleman's Visual Basic Programmer's Guide to the Win32 API
Working With The SavePicture Function
Why do I need SavePicture when I can’t change the picture loaded into the PictureBox anyways? You can. Using Circle, Line, Pset and other drawing methods of the PictureBox control you can draw shapes to the client area of the PictureBox. You can also use PaintPicture to paint from another Form or PictureBox into another … Continue reading Working With The SavePicture Function
Waiting For A Shelled Program To End
Using the Shell method, in any version of Visual Basic, does not allow you to do this. You will need to use an API call and wait for the called program to end. We will discuss how to do this in 16-bit versions of Visual Basic and 32-bit versions. Shelling From Visual Basic 16-bit This … Continue reading Waiting For A Shelled Program To End
Waiting For A Form To Become Inactive
This is a good idea when, for instance, you need a Form to re-paint. CodeSub FormWait (frmIn As Form) Do While frmIn Is Screen.ActiveForm DoEvents LoopEnd Sub UsageFormWait frmMain This tip is reprinted from the VB Tips & Tricks Volume 1 book. Parts of this tip was submitted by: Barth Riely
Using A Password-Protected Database
I found a way to open a database without using INI files at all. Set dbMyDatabase = OpenDatabase(Name:=App.Path & _ "\protected-database.mdb", Exclusive:=False, _ ReadOnly:=False, Connect:=";PWD=marvin") Just provide the password as part of the connect string. This tip is reprinted from the VB Tips & Tricks Volume 1 book. Parts of this tip was submitted … Continue reading Using A Password-Protected Database
Placing The Cursor On The Button That Has Focus
Wouldn't it be nice if you could also place the mouse cursor over that button? Unfortunately, Visual Basic does not have a built-in method to accomplish this. I have found that it is possible to move the mouse cursor by using a Windows API (Application Programmer's Interface) call. The instructions below illustrate how to use … Continue reading Placing The Cursor On The Button That Has Focus
Performance Tip For Using Collections In Visual Basic
Consider the following code: Dim cnCollect As CollectionDim sString As StringDim sKey As StringDim I As IntegerDim vStartDim vFinish vStart = Timer Set cnCollect = New Collection sString = "test" For I = 1 To 1000 sKey = sString & Trim$(Str(I)) cnCollect.Add sString Next I vFinish = Timer txtElapsed.Text = vFinish - vStart On my … Continue reading Performance Tip For Using Collections In Visual Basic

You must be logged in to post a comment.