Category Archives: Microsoft

Protect Form from Accidental Unloading

When you want ot protect the form unload in accidently you can use this following code. In this code, the action is When a form is prepared to unload The unload event was automatically raised on that event there is an parameter named “Cancel” which in the data type integer. When the unload event is raised the “cancel”… Read More »

Remove Extra Spaces from a String

Here is a quick little function to remove extra spaces from within in a string, which might be of help when processing user inputs. Public Function RemoveExtraSpaces(str As String) As String   str = Trim(str)   Dim L As Integer, i As Integer  Dim S As String  Dim Prev_char As String * 1   S = “”   L = Len(str)  i = 1  Do    Prev_char =… Read More »

Determine Even/Odd and Primeness

This is a simple demonstration of one way to determine if a number is even/odd, or prime/not prime. There is very minimal error checking, and the demo can only handle numbers in the range of a long integer. It’s a pretty simple program, meant for beginners to get an idea of how to accomplish this. If you have… Read More »

Simple 3D Text on a Form

Here is some simple code that makes the printed text look sorta 3d, with no OCX or API. Private Sub Form_Load()    Dim ShadowX   Dim ShadowY            ‘Clear Form1   Form1.ScaleMode = 3      ‘Set Scalemode to pixel   Form1.ForeColor = vb3DShadow ‘Change the Forecolor of            ‘Form1 to Shadow Color (Dark grey)   ShadowY = 5         ‘Set The Top of the Shadow   ShadowX = 5      ‘Set The Left of the Shadow   For I = 0… Read More »

11 API Functions for VB6

Here is another handy module from extreme-vb.net. This one covers eleven (11) API-based functions. Notice This content originally appeared on on extreme-vb.net. Permission from Bob Schwarz has been granted to included it here for archival purposes. We can’t reach the future without a bridge to the past. The below table contains a list of the functions, along with… Read More »

String Handling for File Operations

This is a module containing twenty useful functions for working with files, directories, drives, and volumes. Notice This content originally appeared on on extreme-vb.net. Permission from Bob Schwarz has been granted to included it here for archival purposes. We can’t reach the future without a bridge to the past. The below table contains a list of the functions,… Read More »

Convert MB to GB to TB with VB6

This sample project demonstrates not only the conversion of numbers, but also shows how to limit the input of text fields to numbers only. By entering a number in either of the top two boxes, the value will be converted on the fly (as you type) to the other measurements for megabytes, gigabytes, and terabytes. Attachments File Uploaded… Read More »

Crosshairs on Your Form

This example illustrates how to use an instance of the shape object and two lines to cheat a selection rectangle commonly seen in vector based programs like AutoCAD or Microstation. Uses no API. Note This code was originally contributed by Ray Hildenbrand to Visual Basic Code Exchange The site has not been in operation for a number of… Read More »

VB Snippets

These are some small yet handy snippets of code that some folks might find useful. All of the snippets were made using Visual Basic 6.0. They should be compatible with both Visual Basic 5.0 and Visual Basic 6.0. But I can’t be 100% positive on that. If you still use VB 5.0, then you will just have to… Read More »

Finding Last Modified Time for a File

By using API calls from VB6, we can quickly find the most recently used file, quickly. The code below is optimized to quickly find the most recently used file in a specified directory and returns its full name. I’ve also attached a sample project that contains the same information, for easy incorporation in to your project. Note This… Read More »