# Simple Boolean Logic

Page 1 of 1

## 7 Replies - 424 Views - Last Post: 09 December 2012 - 01:18 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=303333&amp;s=a2df43cd208bc81960deaca5c59ccf37&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Sand-Man

Reputation: 0
• Posts: 18
• Joined: 13-November 12

# Simple Boolean Logic

Posted 09 December 2012 - 12:43 PM

hey guys, ive made this form with two textbox's called ( age and RHR ) im asking the client two insert two values and see whether and then hit continue, it seems right but when the two message boxes come up the program gets an error. i cant understand what the error means. i know its probably something silly but yeah. All help appreciated

Public Class HeartData

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim A1 As Boolean
Dim A2 As Boolean

If age.Text = "" Then
A1 = False
End If

If RHR.Text = "" Then
A2 = False
Else : A2 = True
End If
If Age.Text < 0 Then
MsgBox(" Invalid Age ")
A1 = False
Else : A1 = True
End If
If Age.Text > 50 Then
MsgBox(" Your Too Old To Be Using My Program ")
A1 = False
Else : A1 = True
End If

If A1 And A2 = True Then
MsgBox(" Thank You For Your Support")
HeartForm.Show()
Me.Hide()

End If

End Sub

Is This A Good Question/Topic? 0

## Replies To: Simple Boolean Logic

### #2 modi123_1

• Suitor #2

Reputation: 11599
• Posts: 45,763
• Joined: 12-June 08

## Re: Simple Boolean Logic

Posted 09 December 2012 - 12:45 PM

Quote

the program gets an error. i cant understand what the error means.

It's helpful to us to know what the error text is...

### #3 lucky3

• Friend lucky3 As IHelpable

Reputation: 233
• Posts: 770
• Joined: 19-October 11

## Re: Simple Boolean Logic

Posted 09 December 2012 - 12:59 PM

I'll take a wild guess, but imagine scenario with your code, where user enters "lucky3" in Age TextBox, and clicks the Button1. How would your code evaluate if "lucky3" is smaller then 0?

### #4 Sand-Man

Reputation: 0
• Posts: 18
• Joined: 13-November 12

## Re: Simple Boolean Logic

Posted 09 December 2012 - 01:05 PM

thats a really good point, lucky3. how could i make it so that when letters are entered it also become invalid?

and Modi123_1 the error is this :
" Conversion from string "" to type 'Double' is not valid. " but i think thats linked to what lucky3 said .

### #5 lar3ry

• Coding Geezer

Reputation: 313
• Posts: 1,296
• Joined: 12-September 12

## Re: Simple Boolean Logic

Posted 09 December 2012 - 01:07 PM

Assuming the user does not enter Age or RHR...

You ask the user to enter age, then RHR, and then don't give him a chance to enter it, but go ahead and try to convert an empty string to a double.

### #6 Sand-Man

Reputation: 0
• Posts: 18
• Joined: 13-November 12

## Re: Simple Boolean Logic

Posted 09 December 2012 - 01:12 PM

lar3ry, i understand what your trying to say but how would i fix this?

### #7 lar3ry

• Coding Geezer

Reputation: 313
• Posts: 1,296
• Joined: 12-September 12

## Re: Simple Boolean Logic

Posted 09 December 2012 - 01:17 PM

Sand-Man, on 09 December 2012 - 02:05 PM, said:

and Modi123_1 the error is this :
" Conversion from string "" to type 'Double' is not valid. " but i think thats linked to what lucky3 said .

It's ALWAYS a good idea to use Option Strict On (place it above your Class statement). It will tell you what data types are being used incorrectly. Fixing errors pointed out by the editor goes a long way toward a functioning program.

Sand-Man, on 09 December 2012 - 02:12 PM, said:

lar3ry, i understand what your trying to say but how would i fix this?

There are a number of ways. Probably the best is to check both TextBoxes for valid input, put up an appropriate MsgBox, and exit the subroutine. The user would them be able to enter the data and hit the button again.

### #8 Sand-Man

Reputation: 0
• Posts: 18
• Joined: 13-November 12

## Re: Simple Boolean Logic

Posted 09 December 2012 - 01:18 PM

aaah ok i understand thank you, ill post back if its working