Frage deutsch
~~~~~~~~~~~~~~~~
Ich habe spezielle Fragen zu VBDOS
Question English
~~~~~~~~~~~~~~~
I've questions on specific VBDOS funktions.
Answer 1
~~~~~~~~~~~~~~~
[ by Kris Nosack ( knosack@park.uvsc.edu )
from the VBDOS FAQ at the comp.lang.basic.visual newsgroup, June 10, 1994 ]
Perhaps you will find the appropriate answer in our following VBDOS-FAQ:
VISUAL BASIC FOR DOS FAQ
*** How do I break lines of long text into multiple lines of text in the
msgbox?
Use the append a chr$(13) to the end of the string to break lines into
multiple lines. EG:
msg$ = "This is line 1" + chr$(13)
msg$ = msg$ + "This is line 2"
MSGBOX msg$
*** What's the difference between MODAL and MODELESS
forms?
Modal forms are forms which require user input before any other actions can
be taken place. In other words, a modal form has exclusive focus until it is
dismissed. When showing a modal form, the program pauses at the SHOW command
until the modal form is either hidden or unloaded. The internal MSGBOX and
INPUTBOX$ forms are examples of modal forms. To show a form modally, use the
syntax: MyForm.SHOW 1
Modeless forms are those which are shown but do not require immediate user
input. Most child forms (in a MDI application) are typically modeless. To show a
form modeless, use the syntax: MyForm.SHOW
*** When/Why should I use Option Explicit?
8.1. Opinions vary greatly on this subject. The main reason to use the OPTION
EXPLICIT statement at the top of all modules is to minimize the amount of bugs
introduced into your code by misspelling a variable name. Most variants of BASIC
(including VB) have the capability to create variables 'on the fly' (without any
declarations). This capability can be a double edged sword.
At the minimum, it is suggested to use the DEFINT A-Z statement in leu of
OPTION EXPLICIT. This statement will cause any variables which are created on
the fly to be created as integers as opposed to single precisions. (Integers
take up less memory).
The OPTION EXPLICIT statement causes VB to 'disable' it's ability to create
variables on the fly. Thus, all variables must be declared using a DIM or REDIM
statement. All variables not declared will cause an error when the OPTION
EXPLICIT statement is used. This will eliminate any bugs when a variable is
misspelled.
*** Why doesn't PRINT or CLS from a frm module work?
To print information to the screen bypassing the desktop, the commands must
be issued from a .BAS module. All PRINT/CLS output from a form module is
directed to the nul: device.
*** How do I invoke FKey traps which won't be triggered by other keys which
share the same KeyCode?
To trap the only FKeys in events you need to use a combination of the
KeyDown, KeyPress, and KeyUp events.
The basic concept for this is that _all_ keys trap the UP & DOWN events,
while only 'printable' characters trigger the KeyPress event. Thus, when a
character key is pressed, it will trigger the KeyDown, the KeyPress, then the
KeyUp events (in that order). While a FKey (or arrow, or tab, etc...) will
trigger the KeyDown, then the KeyUp events (in that order).
The following code uses a textbox tag property to decide whether a printable
character is pressed or not.
SUB Text1_KeyDown()
Text1.tag = "key"
END SUB
'
SUB Text1_KeyPress()
Text1.tag = ""
END SUB
'
SUB Text1_KeyUp()
IF Text1.tag = "key" then
'--PUT F-KEY HANDLER HERE----
ELSE
'--PUT OTHER KEY HANDLERS HERE----
END IF
END SUB
*** How do I boost memory available to VBDOS.EXE (the
IDE)?
1. Try to have as much EMM available as possible. VBDOS.EXE allocates
subroutines & functions which are < 16K into EMM.
2. To make more conventional mem availble, use the /S:n switch. This will
make VBDOS.EXE use a specific amount of conventional memory. A good compromise
between speed & memory is /S:340. The lower the n value, the slower the
environment runs.
3. Running out of DGROUP usually causes most 'out of memory' errors. Possible
causes are:
- Too many subs & functions exist. Each one takes up 46 bytes of
DGROUP.
- Large static arrays. All static arrays are stored in DGROUP. If a DIM
statement is for a COMMON SHARED statement, the array becomes static. Make the
COMMON SHARED statement appear before the DIM statement to make the array
Dynamic & therefore will not be stored in DGROUP.
- Variable Overhead. Each var has a 4 byte overhead for _each_ module. For
multiple modules projects which use lots of Global (COMMON) statements, this
overhead is repeated for _each_ module.
4. Possible causes for running out conventional memory:
- Not enough EMM.
- Subs or functions which exceed 16K.
- Large arrays. Non-variable length string arrays can be stored in EMM using
the /ea switch.
*** My program runs in the IDE, but won't run when
compiled?
1. Arrays are dynamic by default in the IDE, but when they are compiled, they
are static by default. Therefore, they are stored in DGROUP instead of the far
heap. Use '$DYNAMIC to make all arrays dynamic or use REDIM instead of DIM.
2. Program generates a "program memory overflow" during compile. You need to
break a single module into multiple ones.
*** MISC. Programming TIPS
1. When useing the form designed, to continuously draw controls of a specific
type, hold down the control key when clicking on the appropriate control from
the toolbox.
2. Use the INCLUDE statement to manage large numbers of COMMON SHARED
statements, user defined data types, or external function DECLARES. To use an
include file, simply put all the VBDOS statements that will be shared into a
single file. Save the file as something appropriate. (Typical naming convention
is to use an extension of .BI for basic include files). Then simply insert the
line:
'INCLUDE: 'foobar.bi'
into either your .BAS module, or the module level code in a form.
Answer 2
~~~~~~~~~~~~~
[ from http://crossleo.tripod.com/VBtutor1.htm ]
Getting Started with Microsoft Visual Basic for DOS
This tutorial page will teach you some of the Basics of Microsoft Visual
Basic for Dos. Notice: this tutorial may not contain everything you may need to
know for more information refer to the tutorials in Visual Basic.
*** Believe it or not
Believe it or not Visual Basic is really similar to Qbasic all the commands
are the same exept for one thing the visuals in this program you get to combine
forms or windows with Qbasic programming language.
*** Creating a new form
Go to "File | new form", save the file and then it will come up with the form
editor in which you can edit your window the way you'd like.
In Visual Basic, there is a Properties Bar in which you can change the
properties for the Captation -> it changes the title of the window or
form.
- Frmtype -> changes the kind of Form, Normal form is the one that
you are on right now and the MIDI form is if you are going to have multiple
Forms involved in the program.
- Frmname -> it's the form's name (name is used to call the form.)
There are other functions that you can modify in the properties bar for more
information refer to the Help menu.
*** The Tools
The tools are for creating the elements for your form or window. As you can
see you see a lot of things you can put in your window like Labels, Command
buttos, e.t.c. to see for what they are for refer to the help menu because I
honestly i don't know some of them but this tutorial is yet to be updated as i
learn Visual Basic.
This are the ones i know about so far:
- Command Button -> it's a function button like the one you click
in an error message in windows.
- Labels -> To write Text in your window.
- Directory Box -> to show the Directoryes or folders in the
current Drive
- Drive Box -> it shows the Storage Drives you have like the floppy
disk, Hard drive, e.t.c.
- Frame -> to make a frame around some other elements.
- File list -> shows the current files in the current Directory or
folder
- Text Box -> an input box it allows you to write in it.
*** Event procedures
As I said earlier you can add Qbasic programming to the elements created in
here. If you double click in an element the program will ask you to save and do
so. After that you will see the event procedure window in there you will see the
elements you have created so far.
So click in which form you created it click on your element and then the last
box will have a whole bunch of functions which they explain by theirselves so i
don't think i don't need to mention these in here.
Ok let's suppose we created a command Button. So I selected "Form1 ->
command1 ->Click" and then the program will take you to the Programming
environment Window in which you type your program. But the program will have
already created a sub don't worry about it because it is nessesary.
Example:
Sub Command1_Click
Form1.hide
Form2.show
end sub
The Show command allows you to make a form that is not visible visible. And I
think I know for what Hide is for, it's for making a currently visible window
invisible.
Usage: [Form name].[Show or Hide]
You can also put different commands after the dot which i don't know 'em yet.
Those 2 commands are some of the different commands that are in Visual Basic.
You can also use Qbasic Programming like this one:
Sub Command1_DoubleClick
Shell
end sub
For those of you that have no idea about the shell command the shell command
is for accessing MS-DOS from Qbasic.
*** Combining Qbasic with Visual Basic.
You can combine Qbasic programming with Visual Basic Programming like this
one
Sub Frame1_Click
Textt$ = Text1.text
select case Text1$
CASE "HELLO!"
PRINT "HI!"
END SELECT
END SUB
Also you can add the input from a text box to programming.
Usage:
[Variable] = [Element name].[Kind of element]
The kind of element is like a Text box, Picture Box, Command Button, E.T.C.
So the input from the Element will be transferred to the Variable and then it
can be evaluated by an IF or select case statement.
*** Changing Form's Colors
Create a Form_load event procedure for the 1st form and use this command to
change the Colors from the title bars:
SCREEN.ControlPanel(TITLEBAR_BACKCOLOR) = 1
SCREEN.ControlPanel(TITLEBAR_FORECOLOR) = 15
This will make the colors of the title bar look like window's colors: Blue
backround and white Text color.
*** Changing the Desktop
The Desktop_Backcolor will change the back color of the desktop and the
Desktop_Forecolor will change the Foreground color of the Desktop and
Desktop_Pattern will change the Desktop ASCII Character.
SCREEN.ControlPanel(DESKTOP_BACKCOLOR) = 4
SCREEN.ControlPanel(DESKTOP_FORECOLOR) = 11
SCREEN.ControlPanel(DESKTOP_PATTERN) = 192
Notice: in order to be able to modify the desktop colors you have to add this
line right before the sub declaration
' $INCLUDE: 'CONSTANT.BI'
Well that's all for this small Tutorial I hope this tutorial at least gave
you an small idea of what Visual Basic is capable to do.