8 Replies - 1005 Views - Last Post: 17 April 2012 - 12:57 PM Rate Topic: -----

#1 lemeck  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 25-March 12

how to make a text box's text conditional?

Posted 17 April 2012 - 12:01 PM

hi i just want to ask a code coz im having a problem coz im new in programming ok here is the question


i have a database grade calculation and there is a result for example the result = 86
shown from the grid


then the problem is how to make a text box that has an if and else statement telling if it passed or failed

here is the name of the result label and textbox

Label = Final_GradeLabel
textbox = Final_GradeTextBox




its running its just that i really cant get the if function for database functions hope anyone can help me :)

MOD EDIT: Fixed code tags -- JOAT

This post has been edited by JackOfAllTrades: 17 April 2012 - 12:12 PM
Reason for edit:: changed title to something more descriptive than 'question'


Is This A Good Question/Topic? 0
  • +

Replies To: how to make a text box's text conditional?

#2 DarenR  Icon User is offline

  • D.I.C Lover

Reputation: 387
  • View blog
  • Posts: 2,669
  • Joined: 12-January 10

Re: how to make a text box's text conditional?

Posted 17 April 2012 - 12:06 PM

if textbox.text >= something
then
write it to the text box.
end if
Was This Post Helpful? 1
  • +
  • -

#3 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1292
  • Posts: 2,868
  • Joined: 30-January 11

Re: how to make a text box's text conditional?

Posted 17 April 2012 - 12:09 PM

So have you actually got the result from the database or are you wanting to construct a query to retrieve the results?

When you have the result in an Integer or something say called 'result' you can do something like -

If result > passThreshold Then
    Final_Grade_TextBox.Text = "Passed"
Else
    Final_Grade_TextBox.Text = "Failed"


But again I don't really know what you mean.
Was This Post Helpful? 1
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 5960
  • View blog
  • Posts: 23,238
  • Joined: 23-August 08

Re: how to make a text box's text conditional?

Posted 17 April 2012 - 12:11 PM

1. Don't use titles like "Question". We KNOW you have a question! Give your posts a title that briefly describes the issue, like that to which modi123_1 changed yours.

2. The RIGHT way to use code tags:

:code:
Was This Post Helpful? 1
  • +
  • -

#5 lemeck  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 25-March 12

Re: how to make a text box's text conditional?

Posted 17 April 2012 - 12:25 PM

 
        If Final_GradeTextBox.Text >= 75 Then

            TextBox1.Text = "Passed"

        Else

            TextBox1.Text = "Failed"
        End If



its working but the user need to press anything on the text box to pop out the result any suggestions?

by the way thanks for the code :)
Was This Post Helpful? 0
  • +
  • -

#6 DarenR  Icon User is offline

  • D.I.C Lover

Reputation: 387
  • View blog
  • Posts: 2,669
  • Joined: 12-January 10

Re: how to make a text box's text conditional?

Posted 17 April 2012 - 12:28 PM

try textchanged in the text box if you just want to do it as the text changes
Was This Post Helpful? 1
  • +
  • -

#7 nK0de  Icon User is offline

  • Catch me As Exception
  • member icon

Reputation: 204
  • View blog
  • Posts: 823
  • Joined: 21-December 11

Re: how to make a text box's text conditional?

Posted 17 April 2012 - 12:30 PM

Look into the Textbox's Keypress/Keydown/Textchanged events. Choose whichever suits the best.

This post has been edited by nK0de: 17 April 2012 - 12:31 PM

Was This Post Helpful? 1
  • +
  • -

#8 lemeck  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 25-March 12

Re: how to make a text box's text conditional?

Posted 17 April 2012 - 12:52 PM

haha ok im just gonna make a button result then output it to another textbox thanks for your help :)
Was This Post Helpful? 0
  • +
  • -

#9 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2216
  • View blog
  • Posts: 9,352
  • Joined: 29-May 08

Re: how to make a text box's text conditional?

Posted 17 April 2012 - 12:57 PM

If you enter the text "8" or "9" or "7", will pass as true in your conditional. Probably not what you were think of.

This post has been edited by AdamSpeight2008: 17 April 2012 - 01:01 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1