Solved

Single and double select statements

Posted on 2012-03-13
7
306 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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 46

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

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.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
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…
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…

831 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