Solved

coding basics

Posted on 1998-09-16
7
153 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
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

830 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