6 Replies - 279 Views - Last Post: 30 January 2013 - 03:54 PM Rate Topic: -----

#1 bmruze  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 14-December 12

Check for > 0 in texbox

Posted 30 January 2013 - 03:39 PM

Greetings again,

I am trying to check the value of a textbox, which has data imported from a datagrid, and am needing to check and see if the number imported to the textbox is greater than 0.

I have tried checking for just 0 but it doesn't appear to find it.

If CDbl(TextBoxTier1.Text) > 0 Then RadioButtonTier1.Checked = True


I have also tried
If TextBoxTier1.Text = "0" Then RadioButtonTier1.Checked = False


Thanks for any help.

Is This A Good Question/Topic? 0
  • +

Replies To: Check for > 0 in texbox

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8850
  • View blog
  • Posts: 33,162
  • Joined: 12-June 08

Re: Check for > 0 in texbox

Posted 30 January 2013 - 03:42 PM

Have you put a breakpoint on that if line and checked to see what was even in the textbox? I would suggest doing that first.

Also this asks if the text, converted to a double, is greater than zero.
CDbl(TextBoxTier1.Text) > 0


and this asks if the string value in the textbox is the string "0".
TextBoxTier1.Text = "0"


Two very different things.
Was This Post Helpful? 0
  • +
  • -

#3 rusoaica  Icon User is offline

  • D.I.C Head

Reputation: 27
  • View blog
  • Posts: 193
  • Joined: 10-March 12

Re: Check for > 0 in texbox

Posted 30 January 2013 - 03:48 PM

something like this:

If IsNumeric(textbox.text) Then
   If CInt(textbox.text) > 0 Then
      RadioButton.Checked = True
   End If
End If



IsNumeric is a function that returns a boolean value of true if the parameter can be evaluated as a number. Read about it

CInt is a type converter from something to a number. It will convert your string to an integer, but it will return an error if the text is not a number (thats why we checked if the test is numeric ;D )
Read and learn more about type modifiers here
Was This Post Helpful? 0
  • +
  • -

#4 bmruze  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 14-December 12

Re: Check for > 0 in texbox

Posted 30 January 2013 - 03:49 PM

I have manually entered the value into the DataGrid as 0 and it populates into the text-box correctly. I have a series of 4 radio buttons and 4 text-boxes and am wanting to check one of those radio buttons when the value of the text-box is greater than 0.

Thank you for the clarification on the two methods I was using.
Was This Post Helpful? 0
  • +
  • -

#5 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8850
  • View blog
  • Posts: 33,162
  • Joined: 12-June 08

Re: Check for > 0 in texbox

Posted 30 January 2013 - 03:50 PM

If the textbox value is 0 then.. yes.. your first chunk of code won't work. When is 0 greater than 0?
Was This Post Helpful? 0
  • +
  • -

#6 bmruze  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 14-December 12

Re: Check for > 0 in texbox

Posted 30 January 2013 - 03:51 PM

View Postrusoaica, on 30 January 2013 - 03:48 PM, said:

something like this:

If IsNumeric(textbox.text) Then
   If CInt(textbox.text) > 0 Then
      RadioButton.Checked = True
   End If
End If



IsNumeric is a function that returns a boolean value of true if the parameter can be evaluated as a number. Read about it

CInt is a type converter from something to a number. It will convert your string to an integer, but it will return an error if the text is not a number (thats why we checked if the test is numeric ;D )
Read and learn more about type modifiers here



rusoaica,

Thank you for the information and especially the links. I appreciate the additional information and am grateful for the push in the right direction.
Was This Post Helpful? 0
  • +
  • -

#7 rusoaica  Icon User is offline

  • D.I.C Head

Reputation: 27
  • View blog
  • Posts: 193
  • Joined: 10-March 12

Re: Check for > 0 in texbox

Posted 30 January 2013 - 03:54 PM

glad to help, remember, Google is the best friend of any programmer :bigsmile:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1