Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Single and double select statements

Posted on 2012-03-13
7
Medium Priority
?
328 Views
Last Modified: 2012-04-09
The program should ask for the age of the rider regardless of height, if the rider is under 10 years old the child with adult box must be checked before the child can ride. Here is my program so far

Private Sub cmdOk_Click()
    Dim blnoktoride As Boolean
    blnoktoride = True
   
    'check if rider is legal to ride
    If (Val(txtHeight.Text) < 45) Or (chkBack.Value = 1) Or _
        (chkheart.Value = 1) Then
            blnoktoride = False
    End If
   
    If (Val(txtAge.Text) < 10) And (chkadultchild.Value = 0) Then
        blnoktoride = False
    End If
         
    'display results
    If blnoktoride = True Then
        lblResult.Caption = "ok to ride."
    Else
        lblResult.Caption = "can't ride!"
    End If
   
End Sub

Private Sub txtAge_GotFocus()
    'select text
    txtAge.SelStart = 0
    txtAge.SelStart = Len(txtAge.Text)
End Sub
Private Sub txtHeight_GotFocus()
    'select text
    txtHeight.SelStart = 0
    txtHeight.SelLength = Len(txtHeight.Text)
End Sub
0
Comment
Question by:gorean4u
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 

Author Comment

by:gorean4u
ID: 37718286
No takers, just need someone to check my work
0
 
LVL 32

Expert Comment

by:phoffric
ID: 37718366
Some ideas to get a response:
1) IMO, algorithms is not the right zone for your question.
2) You don't really express a problem. If you are having a problem, then explicitly indicate what you need help in. When you say "check my work", it isn't clear why you need a check. Does your program build ok and run ok? If not, indicate the problem.
3) Put this question in the language zone that you are writing in.
0
 
LVL 32

Expert Comment

by:phoffric
ID: 37718369
You can hit the Request Attention link to get help on changing zones. Or you can delete the question and try again in better zones and by asking a clear question.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37718529
And clearly mark it homework
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 37718776
Is this VBA, VB6, or VB.NET?
0
 

Author Comment

by:gorean4u
ID: 37719934
Thanks
0
 
LVL 49

Accepted Solution

by:
Martin Liss earned 2000 total points
ID: 37720542
I made some changes and comments.

Private Sub cmdOk_Click()
    Dim blnoktoride As Boolean
    blnoktoride = True
   
    'check if rider is legal to ride
    ' Always use the VB built in constants rather that "magic numbers" like = 1
    If (Val(txtHeight.Text) < 45) Or (chkBack.Value = vbChecked) Or _
        (chkheart.Value = vbChecked) Then
            blnoktoride = False
    End If
   
    If (Val(txtAge.Text) < 10) And (chkadultchild.Value = vbUnchecked) Then
        blnoktoride = False
    End If
         
    'display results
    If blnoktoride = True Then
        lblResult.Caption = "ok to ride."
    Else
        lblResult.Caption = "can't ride!"
    End If
   
End Sub

Private Sub txtAge_GotFocus()
    'select text
    txtAge.SelStart = 0
    ' This should be txtAge.SelLength but this really doesn't
    ' do anything useful
    txtAge.SelStart = Len(txtAge.Text)
End Sub
Private Sub txtHeight_GotFocus()
    'select text
    txtHeight.SelStart = 0
    txtHeight.SelLength = Len(txtHeight.Text)
End Sub
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Screencast - Getting to Know the Pipeline
Suggested Courses

610 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