Visual Basic Tips





MsgBox "Hello!"


Dim strName As String

strName = InputBox("Enter name:")

If StrPtr(strName) = 0 Then

MsgBox "Cancel was pressed!"

Else

MsgBox "You didn't press cancel!"

End If

In Visual Basic "" (an empty string) is taken to be the same as vbNullString (an actual null string). If the user presses cancel it is vbNullString which is returned. To distinguish between the two, for a vbNullString the string pointer is zero.


Form1.PrintForm

But be aware that if your form is large, then it probably won't print the whole form, and there is no simple way of changing the paper orientation.


picName.Picture = picName.Image

Form1.PrintForm


Printer.Print "Testing my printer!"

Printer.EndDoc