Focus on Visual Basic

ActiveX Controls

Color Picker

  • Sliders for red, green, and blue. Each slider is shaded to show what colors you can pick, allowing your user to choose colors visually. Of course, your user can also choose colors by entering RGB values manually.
  • Color Picker features properties that allow you to convert colors from RGB format to a long integer and vice versa.
  • Color Picker fires its Changed event when it's colors change. So, you don't have to constantly poll its properties.
  • Color Picker is completely customizable. From its property page, you can turn on and off almost every part of the user interface.
  • This download comes with program that demos each of Color Picker's features.

Snippets

CONTROLS

Determine if a type of control is in a type of a container
Programmatically add a label to the form and set its caption
Find text in a combo box
Adding a horizontal scroll bar to a listbox
Search listbox for a string
Set tab stops in listbox
Place a progress bar in a status bar panel
Find a string in a textbox and highlight
Drag a control at runtime

DATABASE

Connect to SQL Server and MSDE hosts
Start SQL Server 2000 automatically
Build a connection string

PRINTING

Print a big picture on four pages
Loop through the Printers collection until your find the printer you want
Print a FlexGrid

INTERNET

Print the contents of the WebBrowser control
Get HTML with the Microsoft Internet Control

GRAPHICS

Convert WMF Files Into BMP Files
Make a bitmap of a FlexGrid

SYSTEM

Find a window using its title and minimize it
Paste an image into a Word file
Calculate the number of days in a month

STRING MANIPULATION

Zero Fill a Field
Count the number of string occurrences
Soundex String Conversion

Applications

App Data Viewer

Use App Data Viewer to read data directly from any application's controls that are running on your desktop.

Random Encryption Routine

Randomized Key Encryption encrypts a string in such a way that it is never encrypted the same way twice. With some other encryption routines, if two people have the same password, the encrypted passwords are the same. This makes it extremely easy to for other people to guess your password. Using Random Encryption, two identical passwords will be encrypted differently.

Haunted Maze

Haunted Maze is your basic 3d maze game. It's written using DirectX 7 with Visual Basic 6. Although is has an interface only its programmer could love, it has a number of cool features. One thing that this code handles is collision detection. Most other maze programs that I've seen will sometimes allow the user to walk through walls. Others cause the user to 'stick' to the walls. This program not only detects wall collisions. It actually allows the user to slide along a wall he is in contact with (kind of the way you can in Doom or Quake). The 3d maze is generated from a bitmap. So, you can open the bitmap in Paint and change it any way you like.

Haunted Maze features four ghosts that wander the maze. The object of the game is to collect as many diamonds as you can without falling prey to one of the ghosts.

On a side note, one of the books I've been using and highly recomend is Visual Basic(r) Graphics Programming by Rod Stephens.

Haunted Maze (MultiChat version)

This version adds the ability to play over a network. The first user starts the game as a host. Aditional users start the game as players and key in the hosts name and ip address.

The game uses a control array of winsock objects. Whenever a new player joins the game, the host spawns off another winsock object.

In this version, I've created a mostly empty maze to allow the players to see each other better.

 

Solar System Explorer is written using DirectX 8. In Free Flight mode, it allows the user to 'fly' around the Solar System using the arrow keys, space bar, and the B key.
The user can click on a planet and the camera will fly to that planet and hold a relative position. The code demonstrates how to :
  • Add multiple geometry arrays to a vertex buffer
  • Write a general render function driven by an instruction array
  • Make a camera fly around in 3D space

 

Texture Map Resizer DirectX only allows you to use texture map resolutions that are a power of two. This utility lets you quickly resize your maps.