Solved

Single and double select statements

Posted on 2012-03-13
7
317 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
What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

 
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 48

Accepted Solution

by:
Martin Liss earned 500 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
A short article about problems I had with the new location API and permissions in Marshmallow
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…
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…

691 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