Miscellaneous
Can I send keystokes to a dos app?
Compatibility:VB3
VB4
VB5
It is possible to use DOS redirection commands to do that with some apps. For instance, to format your diskdrive, print "Y"(no quotes) to a file name "myfile.txt".
Then do this:
shell "format a: < myfile.txt"
Tada!
Can I compile 16 bit apps in VB5?
Compatibility:VB3
VB4
VB5
No.
How can I check to see if a certain switch has been passed on the command line?
Compatibility:VB3
VB4
VB5
Use this function:
Function GetCommandLine(iMaxArgs As Integer, iArgCnt As Integer)
Dim i As Integer
Dim iCmdLnLen As Integer
Dim iNumArgs As Integer
Dim fInArg As Boolean
Dim cArg As Variant
Dim CmdLine As Variant
If IsMissing(iMaxArgs) Then iMaxArgs = 10
ReDim ArgArray(iMaxArgs)
iNumArgs = 0: fInArg = False
CmdLine = Command()
iCmdLnLen = Len(CmdLine)
For i = 1 To iCmdLnLen
cArg = Mid(CmdLine, i, 1)
If (cArg <> " " And cArg <> vbTab) Then
'Neither space nor tab.
'Test if already in argument.
If Not bInArg Then
'New argument begins.
'Test for too many arguments.
If iNumArgs >= iMaxArgs Then Exit For
iNumArgs = iNumArgs + 1
fInArg = True
End If
'Concatenate character to current argument.
ArgArray(iNumArgs) = ArgArray(iNumArgs) & cArg
Else
'Found a space or tab.
bInArg = False
End If
Next i
'Resize array just enough to hold arguments.
ReDim Preserve ArgArray(iNumArgs)
iArgCnt = iNumArgs
GetCommandLine = ArgArray()
End Function
What does an "Out of Stack space" error message mean?
Compatibility:VB3
VB4
VB5
That means your code in stuck in a infinite loop. For instance, this code will produce that error:
sub badSub()
badSub
end sub
Another, somewhat more subtle example, is if you put this code in a text boxes change event:
text1 = reverse(text1)
(Assuming, of course, you wrote a function to reverse a string named reverse.) When you assign the reverse of text1 to text1, you cause text1_change to fire again. And again. And again.
I have a VB application that loads improperly. Some of the
controls and text boxes are white when the application loads until the
form_load procedure is complete.
Compatibility:VB3
VB4
VB5
You need to put some DoEvents statements in your code. Your Form_Load procedure is usurping the CPU time, and DoEvents give Windows a chance to repaint and process window messages.
I process customer orders, and they come
in batches of tens. I need to round a number to the closest
10, but I can only round up. Otherwise,
the user won't have sufficent product. How can I do this? Plus, is there anyway to round down?
Compatibility:VB3
VB4
VB5
Use these functions:
Function RoundUp(byVal Value as long, Round as long)
RoundUp = ((Value \ Round) + Sgn(Value Mod Round)) * 5
End Function
Function RoundDown(byVal Value as long, Round as long)
RoundUp = Value - (Value mod Round)
End Function
Copyright 2000, David J Berube<Form1@aol.com>. All Rights Reserved.