Solved

coding basics

Posted on 1998-09-16
7
152 Views
Last Modified: 2010-04-30
I have 3 questions. 1) What is the name for the statement placed in your code that allows one to monitor the progress of the code by printing the intermediate values? 2) What is the name for a variable that accepts true/false values? and finally 3) If I wanted to group additional option buttons beyond those directly on the form, what two objects may be used to accomplish this? Thank you.
0
Comment
Question by:gunga
  • 4
  • 2
7 Comments
 

Author Comment

by:gunga
ID: 1435281
Edited text of question
0
 

Author Comment

by:gunga
ID: 1435282
Adjusted points to 150
0
 
LVL 2

Accepted Solution

by:
wj7ster earned 150 total points
ID: 1435283
Answers to your Questions:

Q1.)  'Debug.Print myVariable' will print the value of the myVariable variable to the immediate window.

Q2.) You have to declare a variable as type 'Boolean'.  Declaration as follows:

Dim myVariable     As Boolean

This variable can then only be TRUE or FALSE.  Btw.  False = 0 and True = Not False, i.o.w. any value other than 0 (zero) is regarded as true.

Q3.) You can place 'groups' of option buttons on any container control.  Two other intrinsic controls that you can do this with is the Picturebox and Frame controls.

0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 12

Expert Comment

by:mark2150
ID: 1435284
1) debug.print
2) boolean
3) drop a "Frame" object and all controls inside it will be associated with a group
0
 

Author Comment

by:gunga
ID: 1435285
Would you care to answer this one? How many different constants are possible for the "mbtype" on the message box?
0
 
LVL 2

Expert Comment

by:wj7ster
ID: 1435286
The msgbox function in VB is very flexible.  Just a few basics on this:

It can be used to alert/inform the user or ask a question.

If you are using VB5 then it is easy to get the parameter info and list of properties/methods.

If you want to alert or inform the user you would normally just have an Ok button, the default and would use the MsgBox like this.

MsgBox "This is an alert!", vbExclamation, App.Title

This would bring up a msgbox with an exclamation icon, your application's titla as the caption and the words "This is an alert!" as the text.

You can also use the msgbox to ask a question:

First, we are interested in the user's response, so we create a variable to hold the reponse:

Dim lResponse     As VbMsgBoxResult

   lResponse = MsgBox("Are you sure you want to format your hard drive?", vbQuestion + vbYesNo, App.Title)

' This will prompt the user with a question (a questionmark icon will be displayed on the msgbox) and there will be two buttons, a 'Yes' button and a 'No' button.

' Now we can evaluate the user's answer:
  If lResponse = vbYes then
     ' We format his hard drive
  Else  ' The user selected No
     ' we do nothing
  End If

The constants used to manipulate the msgbox are as follows:

 - modal
vbApplicationModal - Will bring the msgbox to the top of your program.  No other forms will obscure it.
vbSystemModal - will bring the msgbox to the top of all other programs that is open on your desktop.

 - icons
vbCritical - Displays a 'critical' icon on the msgbox
vbExclamation - displays an exclamation icon
vbInformation - displays an information icon
vbQuestion - Shows a question icon

 - defaults
vbDefaultButton1 - makes the first button the default, i.o.w. if the user presses enter instead of clicking on one of the buttons, the first button will be selected.
vbDefaultButton2 - same as above for second button
vbDefaultButton3 - same as above for third button
vbDefaultButton4 - same as above for fourth button

 - help:
vbMsgBoxHelpButton - displays a 'Help' button on the msgbox.  you have to set the 'helpfile' and 'contextid' parameters as well to use this.

 - buttons:
vbOkCancel - displays 'Ok' and 'Cancel' buttons
vbOkOnly - displays only an 'Ok' button (this is the default)
vbRetryCancel - displays 'Retry' and 'Cancel' buttons
vbAbortRetryIgnore - displays the buttons 'Abort' 'Retry 'Ignore'
vbYesNo - displays 'Yes' and 'No' buttons
vbYesNoCancel - displays 'Yes', 'No' and 'Cancel' buttons

You can combine the style by adding (+) the values together from each of the categories listed above.  Not, you cannot add two constant from the same category.

eg to get a msgbox with 'Abort', 'Retry' and 'Ignore' buttons and an exclamation icon that is modal (on top) of all the other forms in your program, you can add

vbAbortRetryIgnore + vbExclamation + vbApplicationModal


Return value:
The possible results that can be returned will be: (I listed the numeric values for each in brackets)

vbAbort (3) - the user selected the 'Abort' button
vbCancel (2) - the user selected the 'Cancel' button
vbIgnore (5) - the user selected the 'Ignore' button
vbNo (7)- the user selected the 'No' button
vbOk (1) - the user selected the 'Ok' button
vbRetry (4) - the user selected the 'Retry' button
vbYes (6) - the user selected the 'Yes' button


For more information, see the on-line help on 'MsgBox'

I hope this helped


Kind regards


Willem Sevenster

0
 

Author Comment

by:gunga
ID: 1435287
Thank you so much for the help/info. I learned quite a lot today.
Much Appreciated.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

805 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question