You can read the full text of past Basically Visual columns. Here I present solutions to a few problems that I have encountered in my programming. Customizing the Web Browser control Avoid using the Internet Transfer control Validating web links Sending email from a Visual Basic program Clear all Text Boxes on a form Create blinking text on a form Display 3-D text on a form Change Text Box margins Aligning controls at a specific position Don't forget the Tag property Sizing a Form's interior Getting colors from a Picture Box control Auto Redraw and the Paint event Capturing screens from a Visual Basic program Filtering Text Box input Getting and using screen information Clipping the mouse cursor Move the mouse cursor in code Drawing "rubber-band" boxes Undo for Text Box controls Disable a form's Close button Modify the System menu Accept only uppercase letters in a Text Box Keeping a form on top Using custom mouse cursors Ensuring that all forms unload Remembering a form's size and position Support formatted text with the Rich Text Box control Toggling a form's title bar at run-time Understanding the Combo Box control Get to know the Sys Info control Changing Combo Box height Implement auto-find in a List Box Selecting all text when a Text Box gets the focus Save time with control arrays Adding controls to a form at runtime Scrolling controls on a form Understanding the Key Preview property Create a pane splitter Changing text alignment for Forms and Picture Boxes Create an "auto-OK" dialog box Create a "Sticky" Button Creating Graphical Command Buttons Implementing mouse-over effects Using the Picture Clip control Implement a Mouse Exit event Fire a Command Button repeatedly Create a temporary file name Verify that a path is writable Determining the type of a drive Using INI files for program settings Deleting files to the recycle bin Dragging files to your Visual Basic program Display file properties Display a select folder dialog Reverse character order in a string Parsing strings Is that on a weekend?
These were originally published in Visual Developer magazine. Perhaps you will find something that is useful to you. Encoding and decoding passwords Implementing a stack Counting strings Converting numbers between decimal and binary Use the Data Report Designer Making the most of UDTs Comparing dates in Visual Basic Using the Collection object Normalize spaces in a string Send raw data to the printer port Creating synthetic keystrokes Detecting the state of the "lock" keys Using the standard input/output streams in Visual Basic Playing WAV files Playing the Windows system sounds Keeping an application log file Detecting a sound card Reduce the size of Visual Basic distribution files Easy creation of database connection strings Do you Do Events?
My task was to use the computer to control a piece of laboratory equipment that was equipped with a parallel interface, but this technique might also be applicable for programming the many other types of parallel port devices, such as external mass storage, that are available today.
Column 1 (April/May 1996): Objects in Visual Basic.
If you need to retrieve HTML pages, you can do so easily by calling some functions in the Win Inet library. First, put the following declarations in your project (in a code module): Public Const INTERNET_OPEN_TYPE_PRECONFIG = 0 Public Const INTERNET_OPEN_TYPE_DIRECT = 1 Public Const INTERNET_OPEN_TYPE_PROXY = 3 Public Const sc User Agent = "VB Open Url" Public Const INTERNET_FLAG_RELOAD = &H80000000 Public Declare Function Internet Open Lib "wininet.dll" Alias "Internet Open A" _ (By Val s Agent As String, By Val l Access Type As Long, By Val s Proxy Name As String, _ By Val s Proxy Bypass As String, By Val l Flags As Long) As Long Public Declare Function Internet Open Url Lib "wininet.dll" Alias "Internet Open Url A" _ (By Val h Open As Long, By Val s Url As String, By Val s Headers As String, _ By Val l Length As Long, By Val l Flags As Long, By Val l Context As Long) As Long Public Declare Function Internet Read File Lib "wininet.dll" _ (By Val h File As Long, By Val s Buffer As String, By Val l Num Bytes To Read As Long, _ l Number Of Bytes Read As Long) As Integer Public Declare Function Internet Close Handle Lib "wininet.dll" _ (By Val h Inet As Long) As Integer Private Function Get HTMLFrom URL(s Url As String) As String Dim s As String Dim h Open As Long Dim h Open Url As Long Dim b Do Loop As Boolean Dim b Ret As Boolean Dim s Read Buffer As String * 2048 Dim l Number Of Bytes Read As Long h Open = Internet Open(sc User Agent, INTERNET_OPEN_TYPE_PRECONFIG, vb Null String, vb Null String, 0) h Open Url = Internet Open Url(h Open, s Url, vb Null String, 0, INTERNET_FLAG_RELOAD, 0) b Do Loop = True While b Do Loop s Read Buffer = vb Null String b Ret = Internet Read File(h Open Url, s Read Buffer, Len(s Read Buffer), l Number Of Bytes Read) s = s & Left$(s Read Buffer, l Number Of Bytes Read) If Not CBool(l Number Of Bytes Read) Then b Do Loop = False Wend If h Open Url While Visual Basic makes some things very easy, other things are ridiculously difficult.
For example, sending raw data to the printer port seems to be impossible.
The solution lay in Visual C , which has the _outp() function to send a byte directly to a hardware port (like Quick Basic's old out() statement). DLL, which you can download in ZIP format by clicking here.
Put the DLL in the \Windows\System folder, then declare the function in your Visual Basic program as follows: The argument p is the port number, which for LPT1: is &H378.