Solved

Single and double select statements

Posted on 2012-03-13
7
309 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
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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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 47

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

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 …
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
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…

730 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