944,093 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
Nov 27th, 2006
0

help!! plz sum one help me FOR GOD SAKE i m crying give me solutions today

Expand Post »
Question # 1:
Ask the user to enter two different numbers. Print all the numbers between the two values they enter.

Question # 2:
Allow the user to enter as many as positive numbers as they wish, and enter zero to indicate they have finished. Then display the number of even values and number of odd values entered by the user. Hint: use the MOD operator to work out weather a number is odd or even.

Question # 3:
Allow the user to enter the password “secret” up to three attempts. Inform the user which attempt they are currently on (1, 2, and 3). Inform the user if the password is correct if they get it, otherwise inform the user the password is incorrect and exit the program.

Question # 4:
Ask the user to “Y”, “N”, “Q” (Quit) in response to this question. “Has” the user passed their driving test?” Continue asking this question until the user answers “Q”. Output the number and percentage of people who have passed their test.
Reputation Points: 10
Solved Threads: 0
Light Poster
sweety0 is offline Offline
47 posts
since Nov 2006
Nov 27th, 2006
0

Re: help!! plz sum one help me FOR GOD SAKE i m crying give me solutions today

We won;t just do the whole thing for you here at DaniWeb. You must at least attempt to do it yourself and post your code when you get stuck then we will help you get it working.

These questions are obviously designed to demonstrate the basic constructs of structured programming Input, looping and decision making and outputing the result.
Reputation Points: 262
Solved Threads: 68
Veteran Poster
hollystyles is offline Offline
1,181 posts
since Feb 2005
Nov 27th, 2006
0

Re: help!! plz sum one help me FOR GOD SAKE i m crying give me solutions today

the code for third question is this


Private Sub Command1_Click()
If Text1.Text = "secret" Then
MsgBox "password is correct"
ElseIf Text1.Text <> "secret" Then
MsgBox "password is incorrect 1st time"
ElseIf Text1.Text <> "secret" Then
MsgBox "password is incorrect 2nd time"
ElseIf Text1.Text <> "secret" Then

MsgBox "password is incorrect 3rd time"

End If
End Sub



the code for question no. 4 is


Private Sub Command1_Click()
If Text1.Text = "Y" Then
MsgBox " yes the user has passed their driving test"
ElseIf Text1.Text = "N" Then
MsgBox " no the user has not passed the driving test"
ElseIf Text1.Text = "Q" Then
End
End If
End Sub
Reputation Points: 10
Solved Threads: 0
Light Poster
sweety0 is offline Offline
47 posts
since Nov 2006
Nov 27th, 2006
0

Re: help!! plz sum one help me FOR GOD SAKE i m crying give me solutions today

Ok first thing put [CODE][\code] (but with CODE in capitals, I have to do lower case otherwise they won't show in the post) tags around code in your posts please, makes it more readable. Thanx.

Ok I think in three what they want you to do is a global variable :

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim guesses As Integer
  2. guesses = 3
  3.  
  4. Private Sub Command1_Click()
  5. If Text1.Text = "secret" Then
  6. MsgBox "password is correct"
  7. Exit Sub
  8. Else
  9. guesses = guesses - 1
  10. MsgBox "password is incorrect. " & guesses & " remaining"
  11. End If
  12.  
  13. If guesses = 0 Then
  14. Me.Unload
  15. End If
  16.  
  17. End Sub

You should ba able to use similar idea for Q4 keep count of answers in two global integer variables failed and passed, increment them as per each yes and no answer. Add a label to your form and set it's text property to something like Label.text = failed & " People failed, " & passed & " People passed."

I've not got VB6 anymore (I assume that's what you're using as your in Vb forum) So I can't check this code, if you get any errors post them word for word and I'll help best I can. Bear with me I am in a full time job and busy busy.
Last edited by hollystyles; Nov 27th, 2006 at 12:05 pm.
Reputation Points: 262
Solved Threads: 68
Veteran Poster
hollystyles is offline Offline
1,181 posts
since Feb 2005
Nov 27th, 2006
0

Re: help!! plz sum one help me FOR GOD SAKE i m crying give me solutions today

hi thnx for the reply
first of all yes, i m using the vb 6 version.
now the problem related to this program is that
the constant "guesses" is not accepting the value 3
and the whole program is perfect but the only error is it is inot stoping on the 3 attempt.
Reputation Points: 10
Solved Threads: 0
Light Poster
sweety0 is offline Offline
47 posts
since Nov 2006
Nov 27th, 2006
0

Re: help!! plz sum one help me FOR GOD SAKE i m crying give me solutions today

Is the message box with guesses remaining always say 3 remaining? or what? can you post your code as it now stands please? I'll see if I can work out your problem.
Reputation Points: 262
Solved Threads: 68
Veteran Poster
hollystyles is offline Offline
1,181 posts
since Feb 2005
Nov 27th, 2006
0

Re: help!! plz sum one help me FOR GOD SAKE i m crying give me solutions today

hi thnx for the reply
first of all yes, i m using the vb 6 version.
now the problem related to this program is that
the constant "guesses" is not accepting the value 3
and the whole program is perfect but the only error is it is inot stoping on the 3 attempt.
Reputation Points: 10
Solved Threads: 0
Light Poster
sweety0 is offline Offline
47 posts
since Nov 2006
Nov 27th, 2006
0

Re: help!! plz sum one help me FOR GOD SAKE i m crying give me solutions today

Your new at this aren't you. come on paste the code I wanna fix it.
Reputation Points: 262
Solved Threads: 68
Veteran Poster
hollystyles is offline Offline
1,181 posts
since Feb 2005
Nov 27th, 2006
0

Re: help!! plz sum one help me FOR GOD SAKE i m crying give me solutions today

Dim guesses As Integer (this is written in the declaration event)

Private Sub Command1_Click()
If Text1.Text = "secret" Then
MsgBox "password is correct"
Exit Sub
Else
guesses = guesses - 1
MsgBox "password is incorrect. " & guesses & " remaining"
End If

If guesses = 0 Then
End
End If

End Sub



now when i enter the wrong password it gives me msg box in which it is written " password is incorrect , -1 remaining"

then on the second attempt "password is incorrect,-2 remaining"

and keeps on increasing the remaining no.
i want that when i make a third attempt the program terminates.
Reputation Points: 10
Solved Threads: 0
Light Poster
sweety0 is offline Offline
47 posts
since Nov 2006
Nov 27th, 2006
0

Re: help!! plz sum one help me FOR GOD SAKE i m crying give me solutions today

Dim guesses As Integer

Private Sub Command1_Click()
If Text1.Text = "secret" Then
MsgBox "password is correct"
Exit Sub
Else
guesses = guesses - 1
MsgBox "password is incorrect. " & guesses & " remaining"
End If

If guesses = 0 Then
End
End If

End Sub
Reputation Points: 10
Solved Threads: 0
Light Poster
sweety0 is offline Offline
47 posts
since Nov 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: need sample codes..
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: thank u so much holly and veena





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC