Showing posts with label Visual Basic. Show all posts
Showing posts with label Visual Basic. Show all posts
Wednesday, May 21, 2008
A guide to win32 APIs.
http://visualbasic.about.com/od/usevb6/l/aa103002a.htm
Tuesday, December 04, 2007
Send Keys Constants
VB: SendKeys Statement
Sends one or more keystrokes to the active window as if typed at the keyboard.
Syntax: SendKeys string[, wait]
The SendKeys statement syntax has these named arguments:
String expression (required) specifying the keystrokes to send
Wait (optional) Boolean value specifying the wait mode. If False (default), control is returned to the procedure immediately after the keys are sent. If True, keystrokes must be processed before control is returned to the procedure.
Remarks
To represent ABC abc 123 use "ABC abc 123" for string.
The plus sign (+), caret (^), percent sign (%), tilde (~), and parentheses ( ) are considered special characters. To specify one of these characters, enclose it within braces ({}). For example, to specify the plus sign, use {+}. Brackets ([ ]) have no special meaning to SendKeys, but you must enclose them in braces. In other applications, brackets do have a special meaning that may be significant when dynamic data exchange (DDE) occurs. To specify brace characters, use {{} and {}}.
To specify non printing keys such as ENTER or TAB, and function keys:
BACKSPACE {BACKSPACE}, {BS}, or {BKSP}
BREAK {BREAK}
CAPS LOCK {CAPSLOCK}
DEL or DELETE {DELETE} or {DEL}
DOWN ARROW {DOWN}
END {END}
ENTER {ENTER} or ~
ESC {ESC}
HELP {HELP}
HOME {HOME}
INS or INSERT {INSERT} or {INS}
LEFT ARROW {LEFT}
NUM LOCK {NUMLOCK}
PAGE DOWN {PGDN}
PAGE UP {PGUP}
PRINT SCREEN {PRTSC}
RIGHT ARROW {RIGHT}
SCROLL LOCK {SCROLLLOCK}
TAB {TAB}
UP ARROW {UP}
F1-F16 {F1}-{F16}
To specify keys combined with any combination of the SHIFT, CTRL, and ALT keys, precede the key code with one or more of the following codes:
SHIFT = +
CTRL = ^
ALT = %
Combination Keys: To specify that any combination of SHIFT, CTRL, and ALT should be held down while several other keys are pressed, enclose the code for those keys in parentheses. For example, to hold down SHIFT while E and C are pressed, use "+(ec)". To specify to hold down SHIFT while E is pressed, followed by C without SHIFT, use "+ec".
Repeating Keys: To specify repeating keys, use the form {key number}. You must put a space between key and number. For example, {LEFT 25} means press the LEFT ARROW key 25 times; {h 15} means press the H key 15 times.
Note: You can't use SendKeys to send keystrokes to an application that is not designed to run in Microsoft Windows. SendKeys also can not send the PRINT SCREEN key {PRTSC} to any application.
List Commands with SendKeys using:
UtilityProvider.ContextValue(_ValueIndex)
ListVarx
ValueIndex is a zero based index for parameter retrieval, x is a one based index for parameter retrieval.
Examples for "Move <1to5>" command where contains UP, DOWN, RIGHT, LEFT and <1to5> contains 1,2,3,4,5
UtilityProvider.ContextValue(ValueIndex) example
SendKeys "{"+UtilityProvider.ContextValue(0)+" "+UtilityProvider.ContextValue(1)+"}"
ListVarx example
SendKeys "{"+ListVar1+" "+ListVar2+"}"
Parameter Conversion and Control Blocks
Convert Parameter to Number Value: block& = val(_arg1)
Convert Number Value to text (CStr(): SendKeys "{Enter}{Up "+CStr(block&)+"}"
If Statement:
if block& = 0 then
sline = "{Shift+End}"
else
sline = "{Shift+Down "+CStr(block&)+"}{Shift+End}"
end if
While Statement
block& = val(_arg1)
loop& = block&
while ( loop& )
Sendkeys "{End}{Enter}"
loop& = loop& - 1
wend
Substring Search Syntax
for list format "Written\Spoken"
Lc% = Instr(_arg1,"\") - 1
TextVal$=MID$(_arg1,0,Lc%)
SendKeys TextVal$
Diagnostic Example: Test List
SendKeys "1. Selected value:{Enter}"
SendKeys ListVar1
SendKeys "{Enter}2. Count to divisor:{Enter}"
Lc% = InStr(ListVar1,"\")
SendKeys CStr(Lc%)
SendKeys "{Enter}3. Count to cutoff:{Enter}"
Lc% = Lc% - 1
SendKeys CStr(Lc%)
SendKeys "{Enter}4. Resulting Value:{Enter}"
TextVal$=Mid$(ListVar1,1,Lc%)
SendKeys TextVal$
SendKeys "{Enter}Command Complete.{Enter}"
Sends one or more keystrokes to the active window as if typed at the keyboard.
Syntax: SendKeys string[, wait]
The SendKeys statement syntax has these named arguments:
String expression (required) specifying the keystrokes to send
Wait (optional) Boolean value specifying the wait mode. If False (default), control is returned to the procedure immediately after the keys are sent. If True, keystrokes must be processed before control is returned to the procedure.
Remarks
To represent ABC abc 123 use "ABC abc 123" for string.
The plus sign (+), caret (^), percent sign (%), tilde (~), and parentheses ( ) are considered special characters. To specify one of these characters, enclose it within braces ({}). For example, to specify the plus sign, use {+}. Brackets ([ ]) have no special meaning to SendKeys, but you must enclose them in braces. In other applications, brackets do have a special meaning that may be significant when dynamic data exchange (DDE) occurs. To specify brace characters, use {{} and {}}.
To specify non printing keys such as ENTER or TAB, and function keys:
BACKSPACE {BACKSPACE}, {BS}, or {BKSP}
BREAK {BREAK}
CAPS LOCK {CAPSLOCK}
DEL or DELETE {DELETE} or {DEL}
DOWN ARROW {DOWN}
END {END}
ENTER {ENTER} or ~
ESC {ESC}
HELP {HELP}
HOME {HOME}
INS or INSERT {INSERT} or {INS}
LEFT ARROW {LEFT}
NUM LOCK {NUMLOCK}
PAGE DOWN {PGDN}
PAGE UP {PGUP}
PRINT SCREEN {PRTSC}
RIGHT ARROW {RIGHT}
SCROLL LOCK {SCROLLLOCK}
TAB {TAB}
UP ARROW {UP}
F1-F16 {F1}-{F16}
To specify keys combined with any combination of the SHIFT, CTRL, and ALT keys, precede the key code with one or more of the following codes:
SHIFT = +
CTRL = ^
ALT = %
Combination Keys: To specify that any combination of SHIFT, CTRL, and ALT should be held down while several other keys are pressed, enclose the code for those keys in parentheses. For example, to hold down SHIFT while E and C are pressed, use "+(ec)". To specify to hold down SHIFT while E is pressed, followed by C without SHIFT, use "+ec".
Repeating Keys: To specify repeating keys, use the form {key number}. You must put a space between key and number. For example, {LEFT 25} means press the LEFT ARROW key 25 times; {h 15} means press the H key 15 times.
Note: You can't use SendKeys to send keystrokes to an application that is not designed to run in Microsoft Windows. SendKeys also can not send the PRINT SCREEN key {PRTSC} to any application.
List Commands with SendKeys using:
UtilityProvider.ContextValue(_ValueIndex)
ListVarx
ValueIndex is a zero based index for parameter retrieval, x is a one based index for parameter retrieval.
Examples for "Move
UtilityProvider.ContextValue(ValueIndex) example
SendKeys "{"+UtilityProvider.ContextValue(0)+" "+UtilityProvider.ContextValue(1)+"}"
ListVarx example
SendKeys "{"+ListVar1+" "+ListVar2+"}"
Parameter Conversion and Control Blocks
Convert Parameter to Number Value: block& = val(_arg1)
Convert Number Value to text (CStr(): SendKeys "{Enter}{Up "+CStr(block&)+"}"
If Statement:
if block& = 0 then
sline = "{Shift+End}"
else
sline = "{Shift+Down "+CStr(block&)+"}{Shift+End}"
end if
While Statement
block& = val(_arg1)
loop& = block&
while ( loop& )
Sendkeys "{End}{Enter}"
loop& = loop& - 1
wend
Substring Search Syntax
for list format "Written\Spoken"
Lc% = Instr(_arg1,"\") - 1
TextVal$=MID$(_arg1,0,Lc%)
SendKeys TextVal$
Diagnostic Example: Test List
SendKeys "1. Selected value:{Enter}"
SendKeys ListVar1
SendKeys "{Enter}2. Count to divisor:{Enter}"
Lc% = InStr(ListVar1,"\")
SendKeys CStr(Lc%)
SendKeys "{Enter}3. Count to cutoff:{Enter}"
Lc% = Lc% - 1
SendKeys CStr(Lc%)
SendKeys "{Enter}4. Resulting Value:{Enter}"
TextVal$=Mid$(ListVar1,1,Lc%)
SendKeys TextVal$
SendKeys "{Enter}Command Complete.{Enter}"
Tuesday, November 20, 2007
Visual Basic 6.0 error 'The memory could not be "read"'.
Problem :The instruction at "0x73d71805" referenced memory at "0x00000000". The memory could not be "read".
Click on OK to terminate the program
Click on CANCEL to debug the program
Solution:
To work around this problem, remove all blank lines that are present before any conditional compilation directives in your Visual Basic 6.0 code.
Click on OK to terminate the program
Click on CANCEL to debug the program
Solution:
To work around this problem, remove all blank lines that are present before any conditional compilation directives in your Visual Basic 6.0 code.
Wednesday, May 30, 2007
Write formatted text in a spreadsheet using VB 6.0
Dim xlApp As Excel.Application
Dim wb As Workbook
Dim ws As Worksheet
Dim rowNum As Integer
Set xlApp = New Excel.Application
Set wb = xlApp.Workbooks.Add()
rowNum = 2
'Specify your worksheet name
Set ws = wb.Worksheets(1)
ws.Name = "BoxCheckReport"
ws.Range(Trim("A1")).Value = "Account No" 'First header row value
ws.Range(Trim("A1")).EntireRow.Font.Bold = True
ws.Range(Trim("A1")).EntireRow.Font.Color = vbBlue
ws.Cells.EntireColumn.ColumnWidth = 25
'ws.Columns.Column(1
ws.Range(Trim("A:A")).NumberFormat = "#####################"
'Set horizontal alignment to Left
xlApp.Range("A:A").HorizontalAlignment = 2
xlApp.Range("B:B").HorizontalAlignment = 2
xlApp.Range("C:C").HorizontalAlignment = 2
xlApp.Range("D:D").HorizontalAlignment = 2
ws.Range(Trim("B1")).Value = "Entry Date" 'header row value
ws.Range(Trim("C1")).Value = "Doc Type" 'header row value
ws.Range(Trim("D1")).Value = "Doc ID" 'header row value
ws.Range(Trim("A2").Value = "1010101010"
ws.Range(Trim("B2").Value = "01/01/02"
ws.Range(Trim("C2").Value = "NAP"
ws.Range(Trim("D2").Value = "001"
wb.SaveAs "c:\ExcelReport.csv"
If Not ws Is Nothing Then
Set ws = Nothing
End If
If Not wb Is Nothing Then
wb.Close
Set wb = Nothing
End If
If Not xlApp Is Nothing Then
xlApp.Quit
Set xlApp = Nothing
End If
'After writing text in the spreadsheet just open it for User to view
ShellExecute 0, vbNullString, "c:\ExcelReport.csv", vbNullString, vbNullString, vbNormalFocus
-----------
OTHER LINKS
-----------
http://www.codeproject.com/vbscript/AssetScan.asp?df=100&forumid=188977&exp=0&select=1268478
http://www.codeguru.com/vb/gen/vb_misc/tips/article.php/c8227/
Dim wb As Workbook
Dim ws As Worksheet
Dim rowNum As Integer
Set xlApp = New Excel.Application
Set wb = xlApp.Workbooks.Add()
rowNum = 2
'Specify your worksheet name
Set ws = wb.Worksheets(1)
ws.Name = "BoxCheckReport"
ws.Range(Trim("A1")).Value = "Account No" 'First header row value
ws.Range(Trim("A1")).EntireRow.Font.Bold = True
ws.Range(Trim("A1")).EntireRow.Font.Color = vbBlue
ws.Cells.EntireColumn.ColumnWidth = 25
'ws.Columns.Column(1
ws.Range(Trim("A:A")).NumberFormat = "#####################"
'Set horizontal alignment to Left
xlApp.Range("A:A").HorizontalAlignment = 2
xlApp.Range("B:B").HorizontalAlignment = 2
xlApp.Range("C:C").HorizontalAlignment = 2
xlApp.Range("D:D").HorizontalAlignment = 2
ws.Range(Trim("B1")).Value = "Entry Date" 'header row value
ws.Range(Trim("C1")).Value = "Doc Type" 'header row value
ws.Range(Trim("D1")).Value = "Doc ID" 'header row value
ws.Range(Trim("A2").Value = "1010101010"
ws.Range(Trim("B2").Value = "01/01/02"
ws.Range(Trim("C2").Value = "NAP"
ws.Range(Trim("D2").Value = "001"
wb.SaveAs "c:\ExcelReport.csv"
If Not ws Is Nothing Then
Set ws = Nothing
End If
If Not wb Is Nothing Then
wb.Close
Set wb = Nothing
End If
If Not xlApp Is Nothing Then
xlApp.Quit
Set xlApp = Nothing
End If
'After writing text in the spreadsheet just open it for User to view
ShellExecute 0, vbNullString, "c:\ExcelReport.csv", vbNullString, vbNullString, vbNormalFocus
-----------
OTHER LINKS
-----------
http://www.codeproject.com/vbscript/AssetScan.asp?df=100&forumid=188977&exp=0&select=1268478
http://www.codeguru.com/vb/gen/vb_misc/tips/article.php/c8227/
Subscribe to:
Posts (Atom)