Solved

Single and double select statements

Posted on 2012-03-13
7
294 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
Comment Utility
No takers, just need someone to check my work
0
 
LVL 32

Expert Comment

by:phoffric
Comment Utility
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
Comment Utility
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 75

Expert Comment

by:Michel Plungjan
Comment Utility
And clearly mark it homework
0
 
LVL 74

Expert Comment

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

Author Comment

by:gorean4u
Comment Utility
Thanks
0
 
LVL 45

Accepted Solution

by:
Martin Liss earned 500 total points
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now