Post on 09-Jan-2016
description
transcript
VB6.0VB6.0
New Interaction Techniques
Department of Computer SciencesUniversity of Tampere, Finland
Department of Computer SciencesUniversity of Tampere, Finland
September – December, 2003
Grigori Evreinov
www.cs.uta.fi/~grse/
Software writing for NIT & usability testing
TAUCHI MMIG G. Evreinov p 01_23 23.09.2003
Objects (Controls)
TextBox
Label
Frame
CommandButton
CheckBox
Shape
Image
PictureBox
MSFlexGrid
Timer
Menu
Software writing for NITVisual
Basic and their general properties
Top, Left, Height, Width
ScaleMode
ScaleTop, ScaleLeft
ScaleHeight, ScaleWidth
Enabled, Visible, Locked
Index (array of objects), TabIndex
Appearance, BackColor,
BorderStyle
Font, ForeColor, Alignment
ToolTipText, MousePointer
other properties
KeyPreview (Form)
MultiLine, ScrollBars, Text
Caption, AutoSize,
WordWrap, BackStyle
Cancel (btn)
Value
Picture, Icon (Form)
AutoRedraw (Form & PicB)
Rows, Cols
Interval
TAUCHI MMIG G. Evreinov p 02_23 23.09.2003
Software writing for NITand their event procedures*
Click, DblClick, KeyDown, KeyPress, KeyUp,
MouseDown, MouseMove, MouseUp
GotFocus, LostFocus
Shape has no event procedures
Timer
Load, Activate, Initialize, Unload, Resize, Terminate
Objects (Controls)
TextBox
Label
Frame
CommandButton
CheckBox
Shape
Image
PictureBox
MSFlexGrid
Timer
Menu
* a procedure is a block of code that performs some operation: Public (is available to all modules), Private (in the current module or form)
TAUCHI MMIG G. Evreinov p 03_23 23.09.2003
Software writing for NITVariables and data types
Boolean 2 bytes (storage size)True or False
Integer (%) 2 bytes -32,768 to 32,767 (256 x 256=65536)
Long (& long integer) 4 bytes -2147483648 to +2147483647
(65536 x 65536=4294967296)
Single (! single-precision) 4 bytes -3.402823E38 to -1.401298E-45 for “-” values;
1.401298E-45 to 3.402823E38 for “+” values.
Double (# double-precision) 8 bytes -1.79769313486232E308 to
-4.94065645841247E-324 for “-” values;
4.94065645841247E-324 to
1.79769313486232E308 for “+” values.
String ($ fixed-length) Length of string in bytes 1 to approximately 65,400 “…”
Variant (by default!) 16 bytes Any numeric value up to the range of a Double.
Byte 1 byte 0 to 255
TAUCHI MMIG G. Evreinov p 04_23 23.09.2003
Software writing for NITother Variables and data types
String(variable-length) 10 bytes + string length 0 to approximately 2 billion
characters (2Hb)
Variant(with characters) 22 bytes + string length Same range as for variable-
length String.
Currency (@ scaled integer) 8 bytes -922,337,203,685,477.5808 to
922,337,203,685,477.5807
Date 8 bytes January 1, 100 to December 31, 9999
Object 4 bytes Any Object reference
User-defined(using Type) Depends upon what elements are used The range of each
element is the same as the range of its data type.
TAUCHI MMIG G. Evreinov p 05_23 23.09.2003
Software writing for NITDeclaration and converting functions*
Dim str1 As Integer, cl1 As Integer
Dim Xtmp As Integer
Dim X As Single
Dim nChar As Integer
Dim CtrlMsk As Boolean
Dim ArrWords(19) As String
Dim LastFile As String, FileName As String
CInt, CLng, CBool, CDate, CStr
Xtmp = Cint(X)
Dim a, b, c As Integer
Variant
Variant
to declare constant
Const PI = 3.14159265
Const SND_LOOP = &H8
to declare function
Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA"
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
* http://www.juicystudio.com/tutorial/vb/variables.html
TAUCHI MMIG G. Evreinov p 06_23 23.09.2003
Software writing for NITObjects (Controls)
Form, PictureBox
TextBox, Label, Frame
CommandButton
CheckBox
Shape
Image
MSFlexGrid, ListBox
supports the following methods*
Cls, Circle, Line, Pset, PaintPicture, PopupMenu, Hide
Refresh, ZOrder, Move, Drag, SetFocus
AddItem, Clear
* a built-in procedure that performs an operation on a specific control
or methods are actions that objects can perform
TAUCHI MMIG G. Evreinov p 07_23 23.09.2003
Software writing for NITFile System Object Methods
CopyFile Used to copy an existing file.
CopyFolder Used to copy an existing folder.
CreateFolder Used to create a folder.
CreateTextFile Used to create a text file.
DeleteFile Used to delete a file.
DeleteFolder Used to delete a folder.
DriveExists Used to determine whether a drive exists.
FileExists Used to determine whether a file exists.
FolderExists Used to determine whether a folder exists.
GetAbsolutePathName Used to return the full path name.
GetDrive Used to return a specified drive.
GetDriveName Used to return the drive name.
GetFile Used to return a specified file.
GetFileName Used to return the file name.
GetFolder Used to return a specified folder.
GetParentFolderName Used to return the name of the
parent folder.
GetTempName Used to create and return a string
representing a file name.
MoveFile Used to move a file.
MoveFolder Used to move a folder.
OpenTextFile Used to open an existing text file.
Common Dialog Box MethodsShowColor Used to display the Color dialog box.
ShowFont Used to display a list of fonts
ShowHelp Used to display a Windows Help File
ShowOpen Used to display the dialog to open files
ShowPrinter Used to display the dialog to open files
ShowSave similar to the ShowOpen method
TAUCHI MMIG G. Evreinov p 08_23 23.09.2003
Functions, most frequently usedAbs(number) ‘b = Abs(-50) b = 50Asc(string) ‘b = Asc(“Apple”) b = 65Dir(pathname,[ attributes]) returns the name of a file, directory, or folder that matches a specified pattern or file attribute
FileName = App.Path & “\TWords.txt”
strFile = Dir(FileName)
If strFile <> “” Then…
Error [(errornumber)] Integer that represents an error number
Debug.Print Error(ErrorNumber)
Hex (number) i = Hex(459) ‘= 1CBRnd[(number)] returns a random number (0-1)
before calling Rnd, use the Randomize statement without anargument to initialize the random-number generator based onthe system timer. to produce random integers in a given range, use this formula:
Int((upperbound - lowerbound + 1) * Rnd + lowerbound) here, upperbound is the highest number in the range, and
lowerbound is the lowest number in the range.
Software writing for NIT
TAUCHI MMIG G. Evreinov p 09_23 23.09.2003
Software writing for NITFunctions, most frequently used
LoadPicture([stringexpression]) returns a picture object (by Commdlg or “….bmp”) imgImage.Picture = LoadPicture()
Str(number) may be used to convert a non-String data type to a String data type
bString = Str(-459.65) ‘ returns “-459.65” backward Val(string)
InStr ([start, ]string1, string2[, compare]) returns the position of the first
occurrence of one string within another
Left(string, length) returns a specified number of characters from the left
side of a string
Len(string | varname) returns the number of chars in a string or the number
of bytes required to store a variable LTrim(string), RTrim(string), Trim(string) return a copy of a string without:
leading spaces (LTrim), trailing spaces (RTrim), or both (Trim). Mid(string, start[, length]) returns a specified number of chars from a string Right(string, length) returns a specified number of chars from the right
side of a stringStrComp(string1, string2[, compare]) performs a binary or textual comparison
[ http://www.juicystudio.com/tutorial/vb/strings.html ]
TAUCHI MMIG G. Evreinov p 10_23 23.09.2003
Software writing for NITFunctions, most frequently used
Sqr(number) returns the square root of a number
Time returns a Variant of subtype Date indicating the current system time Timer returns the number of sec that have elapsed since 12:00AM (midnight) GetTickCount retrieves the number of milliseconds that have elapsed since
12:00AM (midnight) or have elapsed since Windows CE was started
MsgBox(prompt[, buttons*] [, title] [, helpfile, context]) displays a message in a dialog box, waits for the user to clicka button, and returns a value indicating which button the user clicked MsgBox “Error of opening” & FileNameMsgBox “Input's error”, , “SmartStick”
* (0–5) describes the number and type of buttons displayed in the dialog box; 1 – OK, 2 – Cancel, 3 – Abort, 4 – Retry, 5 – Ignore, 6 – Yes, 7 - No (16, 32, 48, 64) describes the icon style; (0, 256, 512, 768) determines which button is the default
TAUCHI MMIG G. Evreinov p 11_23 23.09.2003
Software writing for NITOperators & Statements, most frequently used
[Call] name [argumentlist] Call - optional keyword; name of the procedure to
call; argumentlist - optional. Comma-delimited list of
variables, arrays, or expressions to pass to the procedure.
Call PrintToDebugWindow ("Hello World")
PrintToDebugWindow "Hello World"
[Public | Private] Const constname [As type] = expression declares constants
[Public | Private] Declare Sub name Lib "libname" [Alias "aliasname"] [([arglist])]
or
[Public | Private] Declare Function name Lib "libname" _
[Alias "aliasname"] [([arglist])] [As type]used at the module level to declare references to external procedures in a dynamic-link library
(DLL)
Public Declare Function sndPlaySound Lib “winmm.dll” Alias “sndPlaySoundA” _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long[ http://msdn.microsoft.com/library/en-us/vblr7/html/vastmConst.asp http://msdn.microsoft.com/library/en-us/vblr7/html/vastmCall.asp http://msdn.microsoft.com/library/en-us/vblr7/html/vastmDeclare.asp ]
TAUCHI MMIG G. Evreinov p 12_23 23.09.2003
Software writing for NITOperators & Statements, most frequently used
Dim varname[([subscripts])][, varname[([subscripts])]] . . .
used at module, class, structure, procedure, or block level to
declare and allocate storage space for variables
varname - name of the variable, follows standard variable naming conventions
subscripts - dimensions of an array variable
ReDim [Preserve] varname(subscripts) [, varname(subscripts)] . . .
used at procedure level to reallocate storage space for an array variable
Do…Loop repeats a block of statements while a Boolean condition is True
or until the condition becomes True
For…Next repeats a group of statements a specified number of times
And, Or, Not
[ http://msdn.microsoft.com/library/en-us/vblr7/html/vastmDim.asp
http://msdn.microsoft.com/library/en-us/vblr7/html/vastmReDim.asp
http://msdn.microsoft.com/library/en-us/vblr7/html/vastmDo.asp
http://msdn.microsoft.com/library/en-us/vblr7/html/vastmFor.asp ]
TAUCHI MMIG G. Evreinov p 13_23 23.09.2003
Software writing for NITOperators & Statements, most frequently used
End terminates execution immediatelyExit { Do | For | Function | Property | Select | Sub | Try | While }
exits a procedure or block and transfers control immediately to thestatement following the procedure call or the block definition
Sub ExitStatementDemo() Dim I, iNum As Integer Do ' Set up infinite loop.
For I = 1 To 1000 ' Loop 1000 times. iNum = Int(Rnd * 1000) ' Generate random numbers. Select Case iNum ' Evaluate random number. Case 7: Exit For ' If 7, exit For...Next. Case 29: Exit Do ' If 29, exit Do...Loop. Case 54: Exit Sub ' If 54, exit Sub procedure. End Select Next I Loop End Sub
Close [number] to close the file (number) opened with the help of Open
Load / Unload object[ http://msdn.microsoft.com/library/en-us/vblr7/html/vastmExit.asphttp://msdn.microsoft.com/library/en-us/vblr7/html/vastmEnd.asp ]
EndEnd Function End IfEnd Property End SelectEnd SubEnd TypeEnd With
Exit DoExit ForExit FunctionExit PropertyExit Sub
TAUCHI MMIG G. Evreinov p 14_23 23.09.2003
Software writing for NITUsability-testing
software for…
Clear DataTAUCHI MMIG G. Evreinov p 15_23 23.09.2003
Software writing for NIT
TWords.txt /phrases
GridData1:
test words/chars
entered text /chars
time per char, ms
GridData2:
char per word /phrase
num. of entered words
num. of strokes /clicks per word /phrase
time per word/phrase, s
lblTestSymbol
txtText1
On-screen Keyboard
Break test
Test initialization
Ctrl+K=>move keys
SetSigns
SetCharacters
BackSp
Statistics()
Rtime, ms
s (st.dev), ms
Errors
wpm
TestTime, s
lblSave_Click()
GridData2_Click()to save column
GridData1_Click() to save column
txtPersonData comments…
fraDataWordsLoading
SetTest
lblOpen_Click()
SetData
Trial start
Timer1
Timer2
TAUCHI MMIG G. Evreinov p 16_23 23.09.2003
Software writing for NIT
TWords.txt /phrases
GridData1:
test words/chars
entered text /chars
time per char, mslblTestSymbol
txtText1
On-screen Keyboard
txtPersonData comments…
fraDataWordsLoading
Lesson1
TAUCHI MMIG G. Evreinov p 17_23 23.09.2003
Software writing for NIT
TWords.txt /phrases
GridData1:
test words/chars
entered text /chars
time per char, ms
GridData2:
char per word /phrase
num. of entered words
num. of strokes /clicks per word /phrase
time per word/phrase, s
lblTestSymbol
txtText1
On-screen Keyboard
GridData2_Click()to save column
GridData1_Click() to save column
txtPersonData comments…
fraDataWordsLoading
Lesson2
Clear DataTAUCHI MMIG G. Evreinov p 18_23 23.09.2003
Software writing for NIT
TWords.txt /phrases
GridData1:
test words/chars
entered text /chars
time per char, ms
GridData2:
char per word /phrase
num. of entered words
num. of strokes /clicks per word /phrase
time per word/phrase, s
lblTestSymbol
txtText1
On-screen Keyboard
SetSigns
SetCharacters
BackSp
lblSave_Click()
GridData2_Click()to save column
GridData1_Click() to save column
txtPersonData comments…
fraDataWordsLoading
lblOpen_Click()
Lesson3
TAUCHI MMIG G. Evreinov p 19_23 23.09.2003
Software writing for NITText <> “”
Lesson3
define the Length of the Text
return into the TextBoxplay wave “Empty”
an analysis of the last character
the last Char = Linefeed
remove two last chars in the TextBox
put cursor at the end of the text
play wave “Back Space”
remove the last char in the TextBox
put cursor at the end of the text
play wave “Back Space”
Yes
No
Yes
No
Exit
Exit
Exit
Private Sub BackSp()
* A sample of imaging for algorithm or procedure,
description should be done in a separate paragraph
Clear DataTAUCHI MMIG G. Evreinov p 20_23 23.09.2003
Software writing for NIT
TWords.txt /phrases
GridData1:
test words/chars
entered text /chars
time per char, ms
GridData2:
char per word /phrase
num. of entered words
num. of strokes /clicks per word /phrase
time per word/phrase, s
lblTestSymbol
txtText1
On-screen Keyboard
Ctrl+K=>move keys
SetSigns
SetCharacters
BackSp
lblSave_Click()
GridData2_Click()to save column
GridData1_Click() to save column
txtPersonData comments…
fraDataWordsLoading
lblOpen_Click()
Q
Lesson4
Clear DataTAUCHI MMIG G. Evreinov p 21_23 23.09.2003
Software writing for NIT
TWords.txt /phrases
GridData1:
test words/chars
entered text /chars
time per char, ms
GridData2:
char per word /phrase
num. of entered words
num. of strokes /clicks per word /phrase
time per word/phrase, s
lblTestSymbol
txtText1
On-screen Keyboard
Break test
Test initialization
Ctrl+K=>move keys
SetSigns
SetCharacters
BackSp
lblSave_Click()
GridData2_Click()to save column
GridData1_Click() to save column
txtPersonData comments…
fraDataWordsLoading
SetTest
lblOpen_Click()
SetData
Trial start
Timer1
Timer2
Lesson5
Clear DataTAUCHI MMIG G. Evreinov p 22_23 23.09.2003
Software writing for NIT
TWords.txt /phrases
GridData1:
test words/chars
entered text /chars
time per char, ms
GridData2:
char per word /phrase
num. of entered words
num. of strokes /clicks per word /phrase
time per word/phrase, s
lblTestSymbol
txtText1
On-screen Keyboard
Break test
Test initialization
Ctrl+K=>move keys
SetSigns
SetCharacters
BackSp
Statistics()
Rtime, ms
s (st.dev), ms
Errors
wpm
TestTime, s
lblSave_Click()
GridData2_Click()to save column
GridData1_Click() to save column
txtPersonData comments…
fraDataWordsLoading
SetTest
lblOpen_Click()
SetData
Trial start
Timer1
Timer2
Lesson6
SpotActivate
TAUCHI MMIG G. Evreinov p 23_23 23.09.2003
References
http://msdn.microsoft.com/vbasic/
Visual Basic Language and Run-Time Reference
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vboriVBLangRefTopNode.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vaoriStatementsVBA.asp
http://msdn.microsoft.com/vbasic/downloads/samples/default.asp
VB tutorial http://www.juicystudio.com/tutorial/vb/
http://sunny.moorparkcollege.edu/~kmacone/docs/DataTypes.htm
http://sunny.moorparkcollege.edu/~kmacone/docs/objProc-Prop.htm
http://sunny.moorparkcollege.edu/~kmacone/docs/NamConv.htm
http://www.thescarms.com/vbasic/
http://www.planetsourcecode.com
Interactive Programming (COM132J2)
http://www.infj.ulst.ac.uk/%7Ecnugent/teaching/com148j2/com148j2.htm
http://www.fawcette.com/vsm/
http://www.devx.com/dotnet/Default.asp
Usability testing http://www.tracksys.co.uk/Pages/Usability/usability.htm
Software writing for NIT