July 3, 1999

EscapePressed – Check whether the Esc key was pressed

Private Type POINTAPI x As Long y As LongEnd TypePrivate Type MSGTYPE hWnd As Long message As Long wParam As Long lParam As Long time As Long pt As POINTAPIEnd TypePrivate Declare Function GetInputState Lib “user32” () As LongPrivate Declare Function PeekMessage Lib “user32” Alias “PeekMessageA” (lpMsg _ As MSGTYPE,

LastKeyCode – Get the code of the last key pressed

Private Type POINTAPI x As Long y As LongEnd TypePrivate Type MSGTYPE hWnd As Long message As Long wParam As Long lParam As Long time As Long pt As POINTAPIEnd TypePrivate Declare Function GetInputState Lib “user32” () As LongPrivate Declare Function PeekMessage Lib “user32” Alias “PeekMessageA” (lpMsg _ As MSGTYPE,

BinToDec – Convert from binary to decimal

‘ convert from binary to decimal” NOTE: requires Power2()Function BinToDec(value As String) As Long Dim result As Long, i As Integer, exponent As Integer For i = Len(value) To 1 Step -1 Select Case Asc(Mid$(value, i, 1)) Case 48 ‘ “0”, do nothing Case 49 ‘ “1”, add the corresponding

InstrRev – Backward Instr for VB4 and VB5

‘ A clone of VB6’s InstrRev function (including its quirks)’ that works under VB4 and VB5Function InstrRev(StringCheck As String, StringMatch As String, _ Optional Start As Long = -1, Optional Compare As VbCompareMethod = _ vbBinaryCompare) As Long Dim index As Long Dim lastIndex As Long If Start > Len(StringCheck)

GetUNCName – Convert a file path to a UNC path

‘ Converts a reference to a file in the standard Windows’ format (e.g. “H:ServerDirFilename.ext”) in the corresponding UNC’ format (e.g. “\ServerNameExportedDirServerDirFileName.txt”)” It turns to be very useful when a program running on a workstation’ has to pass a file reference to another app running on another workstation’ or when the

Bin – Convert from decimal to binary

‘ convert from decimal to binary’ if you pass the Digits argument, the result is truncated’ to that number of digits” NOTE: requires Power2()Function Bin(ByVal value As Long, Optional digits As Long = -1) As String Dim result As String, exponent As Integer ‘ this is faster than creating the

Use the WAITFOR Command to Delay a T-SQL Batch Execution

In T-SQL control statements, you can use the WAITFOR command to delay the execution of a T-SQL batch statement block, stored procedure, or transaction. When you specify the DELAY keyword, the execution is delayed for a given amount of time up to a maximum of 24 hours. WAIT FOR DELAY

Class Types Used in Typeid Expressions Must Be Completely Defined

When you use operator typeid, the class type of its argument must be completely defined. This means that a forward declaration of the argument’s base class is insufficient, as in this example: class Base; //forward declaration of a base void func(Base *pb) { if (typeid(*pb) != typeid(Derived)) //trouble do_something(); }

Converting a time_t Value to a tm Struct

For humans, the time_t value is unintelligible. The Standard Library defines the struct tm that can represent date and time in a more readable form. The struct tm is declared in the header as follows: struct tm { int tm_sec; // the number of elapsed seconds in the minute int

No more posts to show