473,414 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Handling empty fields

Hello. I am using Visual Studio .NET (Academic Edition) to write a VB
program. My computer is running Win XP Pro.

I am writing a calculator and requires users to enter two numbers. After
entering the numbers, they should click a button called 'Display Results'.
How can I display a dialog box prompting the users to check their entry if
they left any of the boxes empty? I have tried the .IsNaN function but in
vein.

Thanks.
--
Xero

http://www.chezjeff.net
My personal web portal
Nov 21 '05 #1
14 1567
Hi,

check if isnumeric(textbox.text)
or for the length you could check textbox.text.length > 0
or combine them

hth
Peter
"Xero" <jeff@chezjeff(REMOVE).net> wrote in message
news:F8**********************************@microsof t.com...
Hello. I am using Visual Studio .NET (Academic Edition) to write a VB
program. My computer is running Win XP Pro.

I am writing a calculator and requires users to enter two numbers. After
entering the numbers, they should click a button called 'Display Results'.
How can I display a dialog box prompting the users to check their entry if
they left any of the boxes empty? I have tried the .IsNaN function but in
vein.

Thanks.
--
Xero

http://www.chezjeff.net
My personal web portal

Nov 21 '05 #2
Xero,

To show the result from Peters actions when not
messagebox.show("You should enter something")

I hope this helps?

Cor
"Xero" <jeff@chezjeff(REMOVE).net>
....
Hello. I am using Visual Studio .NET (Academic Edition) to write a VB
program. My computer is running Win XP Pro.

I am writing a calculator and requires users to enter two numbers. After
entering the numbers, they should click a button called 'Display Results'.
How can I display a dialog box prompting the users to check their entry if
they left any of the boxes empty? I have tried the .IsNaN function but in
vein.

Thanks.
--
Xero

http://www.chezjeff.net
My personal web portal

Nov 21 '05 #3
I see. Thanks very much.

"Peter Proost" wrote:
Hi,

check if isnumeric(textbox.text)
or for the length you could check textbox.text.length > 0
or combine them

hth
Peter
"Xero" <jeff@chezjeff(REMOVE).net> wrote in message
news:F8**********************************@microsof t.com...
Hello. I am using Visual Studio .NET (Academic Edition) to write a VB
program. My computer is running Win XP Pro.

I am writing a calculator and requires users to enter two numbers. After
entering the numbers, they should click a button called 'Display Results'.
How can I display a dialog box prompting the users to check their entry if
they left any of the boxes empty? I have tried the .IsNaN function but in
vein.

Thanks.
--
Xero

http://www.chezjeff.net
My personal web portal


Nov 21 '05 #4
Eh ... sorry, I still have some problem ...
I copied the line of code but it didn't work out.

Could you post the exact line of code? I want to display the message 'One of
the boxes is empty.' if any of the two boxes named as 'num1' and 'num2' is
left empty. Thanks again.

"Peter Proost" wrote:
Hi,

check if isnumeric(textbox.text)
or for the length you could check textbox.text.length > 0
or combine them

hth
Peter
"Xero" <jeff@chezjeff(REMOVE).net> wrote in message
news:F8**********************************@microsof t.com...
Hello. I am using Visual Studio .NET (Academic Edition) to write a VB
program. My computer is running Win XP Pro.

I am writing a calculator and requires users to enter two numbers. After
entering the numbers, they should click a button called 'Display Results'.
How can I display a dialog box prompting the users to check their entry if
they left any of the boxes empty? I have tried the .IsNaN function but in
vein.

Thanks.
--
Xero

http://www.chezjeff.net
My personal web portal


Nov 21 '05 #5
Here are 2 possible pieces of code, place it behind the click event of a
button, or where you want to check the textboxes

<<<<<<<code 1>>>>>>

If Not IsNumeric(num1.Text) Or Not IsNumeric(num2.Text) Then
MsgBox("one of the boxes is empty")
End If

<<<<<<code 1>>>>>>

<<<<<<code 2>>>>>>

Dim blnOk As Boolean
If Not IsNumeric(num1.Text) Then
blnOk = False
MsgBox("Box one is empty")
Else
blnOk = True
End If
If Not IsNumeric(num2.Text) Then
blnOk = False
MsgBox("Box two is empty")
Else
blnOk = True
End If

If blnOk Then
'execute the rest of the code
MsgBox("They're both filled")
End If

<<<<<<code 2>>>>>>>>

greetz Peter

"Xero" <jeff@chezjeff(REMOVE).net> wrote in message
news:C0**********************************@microsof t.com...
Eh ... sorry, I still have some problem ...
I copied the line of code but it didn't work out.

Could you post the exact line of code? I want to display the message 'One of the boxes is empty.' if any of the two boxes named as 'num1' and 'num2' is
left empty. Thanks again.

"Peter Proost" wrote:
Hi,

check if isnumeric(textbox.text)
or for the length you could check textbox.text.length > 0
or combine them

hth
Peter
"Xero" <jeff@chezjeff(REMOVE).net> wrote in message
news:F8**********************************@microsof t.com...
Hello. I am using Visual Studio .NET (Academic Edition) to write a VB
program. My computer is running Win XP Pro.

I am writing a calculator and requires users to enter two numbers. After entering the numbers, they should click a button called 'Display Results'. How can I display a dialog box prompting the users to check their entry if they left any of the boxes empty? I have tried the .IsNaN function but in vein.

Thanks.
--
Xero

http://www.chezjeff.net
My personal web portal


Nov 21 '05 #6
Sorry but they don't work either.
The code 'num1.Text' is underlined by a blue line, saying that 'Text is not
a member of Double.'
Sorry that I forgot to tell you that both num1 and num2 are of data type
'Double'.

"Peter Proost" wrote:
Here are 2 possible pieces of code, place it behind the click event of a
button, or where you want to check the textboxes

<<<<<<<code 1>>>>>>

If Not IsNumeric(num1.Text) Or Not IsNumeric(num2.Text) Then
MsgBox("one of the boxes is empty")
End If

<<<<<<code 1>>>>>>

<<<<<<code 2>>>>>>

Dim blnOk As Boolean
If Not IsNumeric(num1.Text) Then
blnOk = False
MsgBox("Box one is empty")
Else
blnOk = True
End If
If Not IsNumeric(num2.Text) Then
blnOk = False
MsgBox("Box two is empty")
Else
blnOk = True
End If

If blnOk Then
'execute the rest of the code
MsgBox("They're both filled")
End If

<<<<<<code 2>>>>>>>>

greetz Peter

"Xero" <jeff@chezjeff(REMOVE).net> wrote in message
news:C0**********************************@microsof t.com...
Eh ... sorry, I still have some problem ...
I copied the line of code but it didn't work out.

Could you post the exact line of code? I want to display the message 'One

of
the boxes is empty.' if any of the two boxes named as 'num1' and 'num2' is
left empty. Thanks again.

"Peter Proost" wrote:
Hi,

check if isnumeric(textbox.text)
or for the length you could check textbox.text.length > 0
or combine them

hth
Peter
"Xero" <jeff@chezjeff(REMOVE).net> wrote in message
news:F8**********************************@microsof t.com...
> Hello. I am using Visual Studio .NET (Academic Edition) to write a VB
> program. My computer is running Win XP Pro.
>
> I am writing a calculator and requires users to enter two numbers. After > entering the numbers, they should click a button called 'Display Results'. > How can I display a dialog box prompting the users to check their entry if > they left any of the boxes empty? I have tried the .IsNaN function but in > vein.
>
> Thanks.
> --
> Xero
>
> http://www.chezjeff.net
> My personal web portal


Nov 21 '05 #7
is it a windows forms application?

grtz Peter
"Xero" <jeff@chezjeff(REMOVE).net> wrote in message
news:D9**********************************@microsof t.com...
Sorry but they don't work either.
The code 'num1.Text' is underlined by a blue line, saying that 'Text is not a member of Double.'
Sorry that I forgot to tell you that both num1 and num2 are of data type
'Double'.

"Peter Proost" wrote:
Here are 2 possible pieces of code, place it behind the click event of a
button, or where you want to check the textboxes

<<<<<<<code 1>>>>>>

If Not IsNumeric(num1.Text) Or Not IsNumeric(num2.Text) Then
MsgBox("one of the boxes is empty")
End If

<<<<<<code 1>>>>>>

<<<<<<code 2>>>>>>

Dim blnOk As Boolean
If Not IsNumeric(num1.Text) Then
blnOk = False
MsgBox("Box one is empty")
Else
blnOk = True
End If
If Not IsNumeric(num2.Text) Then
blnOk = False
MsgBox("Box two is empty")
Else
blnOk = True
End If

If blnOk Then
'execute the rest of the code
MsgBox("They're both filled")
End If

<<<<<<code 2>>>>>>>>

greetz Peter

"Xero" <jeff@chezjeff(REMOVE).net> wrote in message
news:C0**********************************@microsof t.com...
Eh ... sorry, I still have some problem ...
I copied the line of code but it didn't work out.

Could you post the exact line of code? I want to display the message 'One
of
the boxes is empty.' if any of the two boxes named as 'num1' and
'num2' is left empty. Thanks again.

"Peter Proost" wrote:

> Hi,
>
> check if isnumeric(textbox.text)
> or for the length you could check textbox.text.length > 0
> or combine them
>
> hth
> Peter
> "Xero" <jeff@chezjeff(REMOVE).net> wrote in message
> news:F8**********************************@microsof t.com...
> > Hello. I am using Visual Studio .NET (Academic Edition) to write a VB > > program. My computer is running Win XP Pro.
> >
> > I am writing a calculator and requires users to enter two numbers.

After
> > entering the numbers, they should click a button called 'Display

Results'.
> > How can I display a dialog box prompting the users to check their

entry if
> > they left any of the boxes empty? I have tried the .IsNaN function

but in
> > vein.
> >
> > Thanks.
> > --
> > Xero
> >
> > http://www.chezjeff.net
> > My personal web portal
>
>
>


Nov 21 '05 #8
Yes, it is.

"Peter Proost" wrote:
is it a windows forms application?

grtz Peter
"Xero" <jeff@chezjeff(REMOVE).net> wrote in message
news:D9**********************************@microsof t.com...
Sorry but they don't work either.
The code 'num1.Text' is underlined by a blue line, saying that 'Text is

not
a member of Double.'
Sorry that I forgot to tell you that both num1 and num2 are of data type
'Double'.

"Peter Proost" wrote:
Here are 2 possible pieces of code, place it behind the click event of a
button, or where you want to check the textboxes

<<<<<<<code 1>>>>>>

If Not IsNumeric(num1.Text) Or Not IsNumeric(num2.Text) Then
MsgBox("one of the boxes is empty")
End If

<<<<<<code 1>>>>>>

<<<<<<code 2>>>>>>

Dim blnOk As Boolean
If Not IsNumeric(num1.Text) Then
blnOk = False
MsgBox("Box one is empty")
Else
blnOk = True
End If
If Not IsNumeric(num2.Text) Then
blnOk = False
MsgBox("Box two is empty")
Else
blnOk = True
End If

If blnOk Then
'execute the rest of the code
MsgBox("They're both filled")
End If

<<<<<<code 2>>>>>>>>

greetz Peter

"Xero" <jeff@chezjeff(REMOVE).net> wrote in message
news:C0**********************************@microsof t.com...
> Eh ... sorry, I still have some problem ...
> I copied the line of code but it didn't work out.
>
> Could you post the exact line of code? I want to display the message 'One of
> the boxes is empty.' if any of the two boxes named as 'num1' and 'num2' is > left empty. Thanks again.
>
> "Peter Proost" wrote:
>
> > Hi,
> >
> > check if isnumeric(textbox.text)
> > or for the length you could check textbox.text.length > 0
> > or combine them
> >
> > hth
> > Peter
> > "Xero" <jeff@chezjeff(REMOVE).net> wrote in message
> > news:F8**********************************@microsof t.com...
> > > Hello. I am using Visual Studio .NET (Academic Edition) to write a VB > > > program. My computer is running Win XP Pro.
> > >
> > > I am writing a calculator and requires users to enter two numbers.
After
> > > entering the numbers, they should click a button called 'Display
Results'.
> > > How can I display a dialog box prompting the users to check their
entry if
> > > they left any of the boxes empty? I have tried the .IsNaN function but in
> > > vein.
> > >
> > > Thanks.
> > > --
> > > Xero
> > >
> > > http://www.chezjeff.net
> > > My personal web portal
> >
> >
> >


Nov 21 '05 #9
when do you place the entered values in the double variables?

I propbably wont be able to reply anymore untill tomorrow

grtz peter

"Xero" <jeff@chezjeff(REMOVE).net> wrote in message
news:F9**********************************@microsof t.com...
Yes, it is.

"Peter Proost" wrote:
is it a windows forms application?

grtz Peter
"Xero" <jeff@chezjeff(REMOVE).net> wrote in message
news:D9**********************************@microsof t.com...
Sorry but they don't work either.
The code 'num1.Text' is underlined by a blue line, saying that 'Text is
not
a member of Double.'
Sorry that I forgot to tell you that both num1 and num2 are of data
type 'Double'.

"Peter Proost" wrote:

> Here are 2 possible pieces of code, place it behind the click event of a > button, or where you want to check the textboxes
>
> <<<<<<<code 1>>>>>>
>
> If Not IsNumeric(num1.Text) Or Not IsNumeric(num2.Text) Then
> MsgBox("one of the boxes is empty")
> End If
>
> <<<<<<code 1>>>>>>
>
> <<<<<<code 2>>>>>>
>
> Dim blnOk As Boolean
> If Not IsNumeric(num1.Text) Then
> blnOk = False
> MsgBox("Box one is empty")
> Else
> blnOk = True
> End If
> If Not IsNumeric(num2.Text) Then
> blnOk = False
> MsgBox("Box two is empty")
> Else
> blnOk = True
> End If
>
> If blnOk Then
> 'execute the rest of the code
> MsgBox("They're both filled")
> End If
>
> <<<<<<code 2>>>>>>>>
>
> greetz Peter
>
>
>
> "Xero" <jeff@chezjeff(REMOVE).net> wrote in message
> news:C0**********************************@microsof t.com...
> > Eh ... sorry, I still have some problem ...
> > I copied the line of code but it didn't work out.
> >
> > Could you post the exact line of code? I want to display the message 'One
> of
> > the boxes is empty.' if any of the two boxes named as 'num1' and

'num2' is
> > left empty. Thanks again.
> >
> > "Peter Proost" wrote:
> >
> > > Hi,
> > >
> > > check if isnumeric(textbox.text)
> > > or for the length you could check textbox.text.length > 0
> > > or combine them
> > >
> > > hth
> > > Peter
> > > "Xero" <jeff@chezjeff(REMOVE).net> wrote in message
> > > news:F8**********************************@microsof t.com...
> > > > Hello. I am using Visual Studio .NET (Academic Edition) to
write a VB
> > > > program. My computer is running Win XP Pro.
> > > >
> > > > I am writing a calculator and requires users to enter two
numbers. > After
> > > > entering the numbers, they should click a button called 'Display > Results'.
> > > > How can I display a dialog box prompting the users to check their > entry if
> > > > they left any of the boxes empty? I have tried the .IsNaN

function but
> in
> > > > vein.
> > > >
> > > > Thanks.
> > > > --
> > > > Xero
> > > >
> > > > http://www.chezjeff.net
> > > > My personal web portal
> > >
> > >
> > >
>
>
>


Nov 21 '05 #10
Perhaps I should post the lines of code of the event handlier the 'Display
Result' button. Thanks again.

'*******************************
'Begin of code

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim num1 As Double
Dim num2 As Double
num1 = TextBox1.Text
num2 = TextBox2.Text
If reverse.Checked = False Then
If s.Checked Then
MsgBox("The sum of the numbers " & num1 & " and " & num2 & "
is " & num1 + num2 & ".", MsgBoxStyle.Information)
End If
If d.Checked Then
MsgBox("The difference of the numbers " & num1 & " and " &
num2 & " is " & num1 - num2 & ".", MsgBoxStyle.Information)
End If
If m.Checked Then
MsgBox("The multiple of the numbers " & num1 & " and " &
num2 & " is " & num1 * num2 & ".", MsgBoxStyle.Information)
End If
If q.Checked Then
MsgBox("The quotient of the numbers " & num1 & " and " &
num2 & " is " & num1 / num2 & ".", MsgBoxStyle.Information)
End If
End If
If reverse.Checked = True Then
If s.Checked Then
MsgBox("The sum of the numbers " & num1 & " and " & num2 & "
is " & num2 + num1 & ".", MsgBoxStyle.Information)
End If
If d.Checked Then
MsgBox("The difference of the numbers " & num1 & " and " &
num2 & " is " & num2 - num1 & ".", MsgBoxStyle.Information)
End If
If m.Checked Then
MsgBox("The multiple of the numbers " & num1 & " and " &
num2 & " is " & num2 * num1 & ".", MsgBoxStyle.Information)
End If
If q.Checked Then
MsgBox("The quotient of the numbers " & num1 & " and " &
num2 & " is " & num2 / num1 & ".", MsgBoxStyle.Information)
End If
End If
If (s.Checked = False) And (d.Checked = False) And (m.Checked =
False) And (q.Checked = False) Then
MsgBox("No operation key has been selected. Please try again.",
MsgBoxStyle.Exclamation, "Calculator")
End If
End Sub

'End of code
'*******************************
"Peter Proost" wrote:
when do you place the entered values in the double variables?

I propbably wont be able to reply anymore untill tomorrow

grtz peter

"Xero" <jeff@chezjeff(REMOVE).net> wrote in message
news:F9**********************************@microsof t.com...
Yes, it is.

"Peter Proost" wrote:
is it a windows forms application?

grtz Peter
"Xero" <jeff@chezjeff(REMOVE).net> wrote in message
news:D9**********************************@microsof t.com...
> Sorry but they don't work either.
> The code 'num1.Text' is underlined by a blue line, saying that 'Text is not
> a member of Double.'
> Sorry that I forgot to tell you that both num1 and num2 are of data type > 'Double'.
>
> "Peter Proost" wrote:
>
> > Here are 2 possible pieces of code, place it behind the click event of a > > button, or where you want to check the textboxes
> >
> > <<<<<<<code 1>>>>>>
> >
> > If Not IsNumeric(num1.Text) Or Not IsNumeric(num2.Text) Then
> > MsgBox("one of the boxes is empty")
> > End If
> >
> > <<<<<<code 1>>>>>>
> >
> > <<<<<<code 2>>>>>>
> >
> > Dim blnOk As Boolean
> > If Not IsNumeric(num1.Text) Then
> > blnOk = False
> > MsgBox("Box one is empty")
> > Else
> > blnOk = True
> > End If
> > If Not IsNumeric(num2.Text) Then
> > blnOk = False
> > MsgBox("Box two is empty")
> > Else
> > blnOk = True
> > End If
> >
> > If blnOk Then
> > 'execute the rest of the code
> > MsgBox("They're both filled")
> > End If
> >
> > <<<<<<code 2>>>>>>>>
> >
> > greetz Peter
> >
> >
> >
> > "Xero" <jeff@chezjeff(REMOVE).net> wrote in message
> > news:C0**********************************@microsof t.com...
> > > Eh ... sorry, I still have some problem ...
> > > I copied the line of code but it didn't work out.
> > >
> > > Could you post the exact line of code? I want to display the message 'One
> > of
> > > the boxes is empty.' if any of the two boxes named as 'num1' and
'num2' is
> > > left empty. Thanks again.
> > >
> > > "Peter Proost" wrote:
> > >
> > > > Hi,
> > > >
> > > > check if isnumeric(textbox.text)
> > > > or for the length you could check textbox.text.length > 0
> > > > or combine them
> > > >
> > > > hth
> > > > Peter
> > > > "Xero" <jeff@chezjeff(REMOVE).net> wrote in message
> > > > news:F8**********************************@microsof t.com...
> > > > > Hello. I am using Visual Studio .NET (Academic Edition) to write a VB
> > > > > program. My computer is running Win XP Pro.
> > > > >
> > > > > I am writing a calculator and requires users to enter two numbers. > > After
> > > > > entering the numbers, they should click a button called 'Display > > Results'.
> > > > > How can I display a dialog box prompting the users to check their > > entry if
> > > > > they left any of the boxes empty? I have tried the .IsNaN function but
> > in
> > > > > vein.
> > > > >
> > > > > Thanks.
> > > > > --
> > > > > Xero
> > > > >
> > > > > http://www.chezjeff.net
> > > > > My personal web portal
> > > >
> > > >
> > > >
> >
> >
> >


Nov 21 '05 #11
Hi, this code should do the trick

<<<<<<<<<<code>>>>>>>>>>>>

Dim num1 As Double
Dim num2 As Double
Dim blnOk As Boolean = True
If Not IsNumeric(TextBox1.Text) Then
blnOk = False
MsgBox("Box one is empty")
Else
num1 = TextBox1.Text
blnOk = True
End If
If Not IsNumeric(TextBox2.Text) Then
blnOk = False
MsgBox("Box two is empty")
Else
num2 = TextBox2.Text
blnOk = True
End If

If blnOk Then
If reverse.Checked = False Then
If s.Checked Then
MsgBox("The sum of the numbers " & num1 & " and " & num2
& " is " & num1 + num2 & ".", MsgBoxStyle.Information)
End If
If d.Checked Then
MsgBox("The difference of the numbers " & num1 & " and "
& num2 & " is " & num1 - num2 & ".", MsgBoxStyle.Information)
End If
If m.Checked Then
MsgBox("The multiple of the numbers " & num1 & " and " &
num2 & " is " & num1 * num2 & ".", MsgBoxStyle.Information)
End If
If q.Checked Then
MsgBox("The quotient of the numbers " & num1 & " and " &
num2 & " is " & num1 / num2 & ".", MsgBoxStyle.Information)
End If
End If
If reverse.Checked = True Then
If s.Checked Then
MsgBox("The sum of the numbers " & num1 & " and " & num2
& " is " & num2 + num1 & ".", MsgBoxStyle.Information)
End If
If d.Checked Then
MsgBox("The difference of the numbers " & num1 & " and "
& num2 & " is " & num2 - num1 & ".", MsgBoxStyle.Information)
End If
If m.Checked Then
MsgBox("The multiple of the numbers " & num1 & " and " &
num2 & " is " & num2 * num1 & ".", MsgBoxStyle.Information)
End If
If q.Checked Then
MsgBox("The quotient of the numbers " & num1 & " and " &
num2 & " is " & num2 / num1 & ".", MsgBoxStyle.Information)
End If
End If
If (s.Checked = False) And (d.Checked = False) And (m.Checked =
False) And (q.Checked = False) Then
MsgBox("No operation key has been selected. Please try
again.", MsgBoxStyle.Exclamation, "Calculator")
End If
End If

<<<<<<<<<code>>>>>>>>

greetz Peter
"Xero" <jeff@chezjeff(REMOVE).net> wrote in message
news:C3**********************************@microsof t.com...
Perhaps I should post the lines of code of the event handlier the 'Display
Result' button. Thanks again.

'*******************************
'Begin of code

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim num1 As Double
Dim num2 As Double
num1 = TextBox1.Text
num2 = TextBox2.Text
If reverse.Checked = False Then
If s.Checked Then
MsgBox("The sum of the numbers " & num1 & " and " & num2 & " is " & num1 + num2 & ".", MsgBoxStyle.Information)
End If
If d.Checked Then
MsgBox("The difference of the numbers " & num1 & " and " &
num2 & " is " & num1 - num2 & ".", MsgBoxStyle.Information)
End If
If m.Checked Then
MsgBox("The multiple of the numbers " & num1 & " and " &
num2 & " is " & num1 * num2 & ".", MsgBoxStyle.Information)
End If
If q.Checked Then
MsgBox("The quotient of the numbers " & num1 & " and " &
num2 & " is " & num1 / num2 & ".", MsgBoxStyle.Information)
End If
End If
If reverse.Checked = True Then
If s.Checked Then
MsgBox("The sum of the numbers " & num1 & " and " & num2 & " is " & num2 + num1 & ".", MsgBoxStyle.Information)
End If
If d.Checked Then
MsgBox("The difference of the numbers " & num1 & " and " &
num2 & " is " & num2 - num1 & ".", MsgBoxStyle.Information)
End If
If m.Checked Then
MsgBox("The multiple of the numbers " & num1 & " and " &
num2 & " is " & num2 * num1 & ".", MsgBoxStyle.Information)
End If
If q.Checked Then
MsgBox("The quotient of the numbers " & num1 & " and " &
num2 & " is " & num2 / num1 & ".", MsgBoxStyle.Information)
End If
End If
If (s.Checked = False) And (d.Checked = False) And (m.Checked =
False) And (q.Checked = False) Then
MsgBox("No operation key has been selected. Please try again.", MsgBoxStyle.Exclamation, "Calculator")
End If
End Sub

'End of code
'*******************************
"Peter Proost" wrote:
when do you place the entered values in the double variables?

I propbably wont be able to reply anymore untill tomorrow

grtz peter

"Xero" <jeff@chezjeff(REMOVE).net> wrote in message
news:F9**********************************@microsof t.com...
Yes, it is.

"Peter Proost" wrote:

> is it a windows forms application?
>
> grtz Peter
>
>
> "Xero" <jeff@chezjeff(REMOVE).net> wrote in message
> news:D9**********************************@microsof t.com...
> > Sorry but they don't work either.
> > The code 'num1.Text' is underlined by a blue line, saying that 'Text
is
> not
> > a member of Double.'
> > Sorry that I forgot to tell you that both num1 and num2 are of
data type
> > 'Double'.
> >
> > "Peter Proost" wrote:
> >
> > > Here are 2 possible pieces of code, place it behind the click ev
ent of a
> > > button, or where you want to check the textboxes
> > >
> > > <<<<<<<code 1>>>>>>
> > >
> > > If Not IsNumeric(num1.Text) Or Not IsNumeric(num2.Text) Then
> > > MsgBox("one of the boxes is empty")
> > > End If
> > >
> > > <<<<<<code 1>>>>>>
> > >
> > > <<<<<<code 2>>>>>>
> > >
> > > Dim blnOk As Boolean
> > > If Not IsNumeric(num1.Text) Then
> > > blnOk = False
> > > MsgBox("Box one is empty")
> > > Else
> > > blnOk = True
> > > End If
> > > If Not IsNumeric(num2.Text) Then
> > > blnOk = False
> > > MsgBox("Box two is empty")
> > > Else
> > > blnOk = True
> > > End If
> > >
> > > If blnOk Then
> > > 'execute the rest of the code
> > > MsgBox("They're both filled")
> > > End If
> > >
> > > <<<<<<code 2>>>>>>>>
> > >
> > > greetz Peter
> > >
> > >
> > >
> > > "Xero" <jeff@chezjeff(REMOVE).net> wrote in message
> > > news:C0**********************************@microsof t.com...
> > > > Eh ... sorry, I still have some problem ...
> > > > I copied the line of code but it didn't work out.
> > > >
> > > > Could you post the exact line of code? I want to display the

message
> 'One
> > > of
> > > > the boxes is empty.' if any of the two boxes named as 'num1'
and > 'num2' is
> > > > left empty. Thanks again.
> > > >
> > > > "Peter Proost" wrote:
> > > >
> > > > > Hi,
> > > > >
> > > > > check if isnumeric(textbox.text)
> > > > > or for the length you could check textbox.text.length > 0
> > > > > or combine them
> > > > >
> > > > > hth
> > > > > Peter
> > > > > "Xero" <jeff@chezjeff(REMOVE).net> wrote in message
> > > > > news:F8**********************************@microsof t.com...
> > > > > > Hello. I am using Visual Studio .NET (Academic Edition) to

write a
> VB
> > > > > > program. My computer is running Win XP Pro.
> > > > > >
> > > > > > I am writing a calculator and requires users to enter two

numbers.
> > > After
> > > > > > entering the numbers, they should click a button called

'Display
> > > Results'.
> > > > > > How can I display a dialog box prompting the users to

check their
> > > entry if
> > > > > > they left any of the boxes empty? I have tried the .IsNaN

function
> but
> > > in
> > > > > > vein.
> > > > > >
> > > > > > Thanks.
> > > > > > --
> > > > > > Xero
> > > > > >
> > > > > > http://www.chezjeff.net
> > > > > > My personal web portal
> > > > >
> > > > >
> > > > >
> > >
> > >
> > >
>
>
>


Nov 21 '05 #12
It won't work either ...
An error box containing the following message appeared:
An unhandled exception of type 'System.InvalidCastException' occurred in
microsoft.visualbasic.dll

Additional information: Cast from string "" to type 'Double' is not valid.
"Peter Proost" wrote:
Hi, this code should do the trick

<<<<<<<<<<code>>>>>>>>>>>>

Dim num1 As Double
Dim num2 As Double
Dim blnOk As Boolean = True
If Not IsNumeric(TextBox1.Text) Then
blnOk = False
MsgBox("Box one is empty")
Else
num1 = TextBox1.Text
blnOk = True
End If
If Not IsNumeric(TextBox2.Text) Then
blnOk = False
MsgBox("Box two is empty")
Else
num2 = TextBox2.Text
blnOk = True
End If

If blnOk Then
If reverse.Checked = False Then
If s.Checked Then
MsgBox("The sum of the numbers " & num1 & " and " & num2
& " is " & num1 + num2 & ".", MsgBoxStyle.Information)
End If
If d.Checked Then
MsgBox("The difference of the numbers " & num1 & " and "
& num2 & " is " & num1 - num2 & ".", MsgBoxStyle.Information)
End If
If m.Checked Then
MsgBox("The multiple of the numbers " & num1 & " and " &
num2 & " is " & num1 * num2 & ".", MsgBoxStyle.Information)
End If
If q.Checked Then
MsgBox("The quotient of the numbers " & num1 & " and " &
num2 & " is " & num1 / num2 & ".", MsgBoxStyle.Information)
End If
End If
If reverse.Checked = True Then
If s.Checked Then
MsgBox("The sum of the numbers " & num1 & " and " & num2
& " is " & num2 + num1 & ".", MsgBoxStyle.Information)
End If
If d.Checked Then
MsgBox("The difference of the numbers " & num1 & " and "
& num2 & " is " & num2 - num1 & ".", MsgBoxStyle.Information)
End If
If m.Checked Then
MsgBox("The multiple of the numbers " & num1 & " and " &
num2 & " is " & num2 * num1 & ".", MsgBoxStyle.Information)
End If
If q.Checked Then
MsgBox("The quotient of the numbers " & num1 & " and " &
num2 & " is " & num2 / num1 & ".", MsgBoxStyle.Information)
End If
End If
If (s.Checked = False) And (d.Checked = False) And (m.Checked =
False) And (q.Checked = False) Then
MsgBox("No operation key has been selected. Please try
again.", MsgBoxStyle.Exclamation, "Calculator")
End If
End If

<<<<<<<<<code>>>>>>>>

greetz Peter
"Xero" <jeff@chezjeff(REMOVE).net> wrote in message
news:C3**********************************@microsof t.com...
Perhaps I should post the lines of code of the event handlier the 'Display
Result' button. Thanks again.

'*******************************
'Begin of code

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim num1 As Double
Dim num2 As Double
num1 = TextBox1.Text
num2 = TextBox2.Text
If reverse.Checked = False Then
If s.Checked Then
MsgBox("The sum of the numbers " & num1 & " and " & num2 &

"
is " & num1 + num2 & ".", MsgBoxStyle.Information)
End If
If d.Checked Then
MsgBox("The difference of the numbers " & num1 & " and " &
num2 & " is " & num1 - num2 & ".", MsgBoxStyle.Information)
End If
If m.Checked Then
MsgBox("The multiple of the numbers " & num1 & " and " &
num2 & " is " & num1 * num2 & ".", MsgBoxStyle.Information)
End If
If q.Checked Then
MsgBox("The quotient of the numbers " & num1 & " and " &
num2 & " is " & num1 / num2 & ".", MsgBoxStyle.Information)
End If
End If
If reverse.Checked = True Then
If s.Checked Then
MsgBox("The sum of the numbers " & num1 & " and " & num2 &

"
is " & num2 + num1 & ".", MsgBoxStyle.Information)
End If
If d.Checked Then
MsgBox("The difference of the numbers " & num1 & " and " &
num2 & " is " & num2 - num1 & ".", MsgBoxStyle.Information)
End If
If m.Checked Then
MsgBox("The multiple of the numbers " & num1 & " and " &
num2 & " is " & num2 * num1 & ".", MsgBoxStyle.Information)
End If
If q.Checked Then
MsgBox("The quotient of the numbers " & num1 & " and " &
num2 & " is " & num2 / num1 & ".", MsgBoxStyle.Information)
End If
End If
If (s.Checked = False) And (d.Checked = False) And (m.Checked =
False) And (q.Checked = False) Then
MsgBox("No operation key has been selected. Please try

again.",
MsgBoxStyle.Exclamation, "Calculator")
End If
End Sub

'End of code
'*******************************
"Peter Proost" wrote:
when do you place the entered values in the double variables?

I propbably wont be able to reply anymore untill tomorrow

grtz peter

"Xero" <jeff@chezjeff(REMOVE).net> wrote in message
news:F9**********************************@microsof t.com...
> Yes, it is.
>
> "Peter Proost" wrote:
>
> > is it a windows forms application?
> >
> > grtz Peter
> >
> >
> > "Xero" <jeff@chezjeff(REMOVE).net> wrote in message
> > news:D9**********************************@microsof t.com...
> > > Sorry but they don't work either.
> > > The code 'num1.Text' is underlined by a blue line, saying that 'Text is
> > not
> > > a member of Double.'
> > > Sorry that I forgot to tell you that both num1 and num2 are of data type
> > > 'Double'.
> > >
> > > "Peter Proost" wrote:
> > >
> > > > Here are 2 possible pieces of code, place it behind the click ev ent of a
> > > > button, or where you want to check the textboxes
> > > >
> > > > <<<<<<<code 1>>>>>>
> > > >
> > > > If Not IsNumeric(num1.Text) Or Not IsNumeric(num2.Text) Then
> > > > MsgBox("one of the boxes is empty")
> > > > End If
> > > >
> > > > <<<<<<code 1>>>>>>
> > > >
> > > > <<<<<<code 2>>>>>>
> > > >
> > > > Dim blnOk As Boolean
> > > > If Not IsNumeric(num1.Text) Then
> > > > blnOk = False
> > > > MsgBox("Box one is empty")
> > > > Else
> > > > blnOk = True
> > > > End If
> > > > If Not IsNumeric(num2.Text) Then
> > > > blnOk = False
> > > > MsgBox("Box two is empty")
> > > > Else
> > > > blnOk = True
> > > > End If
> > > >
> > > > If blnOk Then
> > > > 'execute the rest of the code
> > > > MsgBox("They're both filled")
> > > > End If
> > > >
> > > > <<<<<<code 2>>>>>>>>
> > > >
> > > > greetz Peter
> > > >
> > > >
> > > >
> > > > "Xero" <jeff@chezjeff(REMOVE).net> wrote in message
> > > > news:C0**********************************@microsof t.com...
> > > > > Eh ... sorry, I still have some problem ...
> > > > > I copied the line of code but it didn't work out.
> > > > >
> > > > > Could you post the exact line of code? I want to display the
message
> > 'One
> > > > of
> > > > > the boxes is empty.' if any of the two boxes named as 'num1' and > > 'num2' is
> > > > > left empty. Thanks again.
> > > > >
> > > > > "Peter Proost" wrote:
> > > > >
> > > > > > Hi,
> > > > > >
> > > > > > check if isnumeric(textbox.text)
> > > > > > or for the length you could check textbox.text.length > 0
> > > > > > or combine them
> > > > > >
> > > > > > hth
> > > > > > Peter
> > > > > > "Xero" <jeff@chezjeff(REMOVE).net> wrote in message
> > > > > > news:F8**********************************@microsof t.com...
> > > > > > > Hello. I am using Visual Studio .NET (Academic Edition) to
write a
> > VB
> > > > > > > program. My computer is running Win XP Pro.
> > > > > > >
> > > > > > > I am writing a calculator and requires users to enter two
numbers.
> > > > After
> > > > > > > entering the numbers, they should click a button called
'Display
> > > > Results'.
> > > > > > > How can I display a dialog box prompting the users to check their
> > > > entry if
> > > > > > > they left any of the boxes empty? I have tried the .IsNaN
function
> > but
> > > > in
> > > > > > > vein.
> > > > > > >
> > > > > > > Thanks.
> > > > > > > --
> > > > > > > Xero
> > > > > > >
> > > > > > > http://www.chezjeff.net
> > > > > > > My personal web portal
> > > > > >
> > > > > >
> > > > > >
> > > >
> > > >
> > > >
> >
> >
> >


Nov 21 '05 #13
place num1 = cdbl(TextBox1.Text) and num2 = cdbl(TextBox2.Text) instead of
num1 = TextBox1.Text and num2 = TextBox2.Text, you probably have option
strict on that's what generates the error.

this piece of code I tested and works just fine:

<<<<<<code>>>>>>>
Dim num1 As Double
Dim num2 As Double
Dim blnOk As Boolean = True

If Not IsNumeric(TextBox1.Text) Then
blnOk = False
MsgBox("Box one is empty")
Else
num1 = CDbl(TextBox1.Text)
blnOk = True
End If

If Not IsNumeric(TextBox2.Text) Then
blnOk = False
MsgBox("Box two is empty")
Else
num2 = CDbl(TextBox2.Text)
blnOk = True
End If

<<<<<<code>>>>>>

greetz Peter

"Xero" <jeff@chezjeff(REMOVE).net> wrote in message
news:70**********************************@microsof t.com...
It won't work either ...
An error box containing the following message appeared:
An unhandled exception of type 'System.InvalidCastException' occurred in
microsoft.visualbasic.dll

Additional information: Cast from string "" to type 'Double' is not valid.
"Peter Proost" wrote:
Hi, this code should do the trick

<<<<<<<<<<code>>>>>>>>>>>>

Dim num1 As Double
Dim num2 As Double
Dim blnOk As Boolean = True
If Not IsNumeric(TextBox1.Text) Then
blnOk = False
MsgBox("Box one is empty")
Else
num1 = TextBox1.Text
blnOk = True
End If
If Not IsNumeric(TextBox2.Text) Then
blnOk = False
MsgBox("Box two is empty")
Else
num2 = TextBox2.Text
blnOk = True
End If

If blnOk Then
If reverse.Checked = False Then
If s.Checked Then
MsgBox("The sum of the numbers " & num1 & " and " & num2 & " is " & num1 + num2 & ".", MsgBoxStyle.Information)
End If
If d.Checked Then
MsgBox("The difference of the numbers " & num1 & " and " & num2 & " is " & num1 - num2 & ".", MsgBoxStyle.Information)
End If
If m.Checked Then
MsgBox("The multiple of the numbers " & num1 & " and " & num2 & " is " & num1 * num2 & ".", MsgBoxStyle.Information)
End If
If q.Checked Then
MsgBox("The quotient of the numbers " & num1 & " and " & num2 & " is " & num1 / num2 & ".", MsgBoxStyle.Information)
End If
End If
If reverse.Checked = True Then
If s.Checked Then
MsgBox("The sum of the numbers " & num1 & " and " & num2 & " is " & num2 + num1 & ".", MsgBoxStyle.Information)
End If
If d.Checked Then
MsgBox("The difference of the numbers " & num1 & " and " & num2 & " is " & num2 - num1 & ".", MsgBoxStyle.Information)
End If
If m.Checked Then
MsgBox("The multiple of the numbers " & num1 & " and " & num2 & " is " & num2 * num1 & ".", MsgBoxStyle.Information)
End If
If q.Checked Then
MsgBox("The quotient of the numbers " & num1 & " and " & num2 & " is " & num2 / num1 & ".", MsgBoxStyle.Information)
End If
End If
If (s.Checked = False) And (d.Checked = False) And (m.Checked = False) And (q.Checked = False) Then
MsgBox("No operation key has been selected. Please try
again.", MsgBoxStyle.Exclamation, "Calculator")
End If
End If

<<<<<<<<<code>>>>>>>>

greetz Peter
"Xero" <jeff@chezjeff(REMOVE).net> wrote in message
news:C3**********************************@microsof t.com...
Perhaps I should post the lines of code of the event handlier the 'Display Result' button. Thanks again.

'*******************************
'Begin of code

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim num1 As Double
Dim num2 As Double
num1 = TextBox1.Text
num2 = TextBox2.Text
If reverse.Checked = False Then
If s.Checked Then
MsgBox("The sum of the numbers " & num1 & " and " & num2 &
"
is " & num1 + num2 & ".", MsgBoxStyle.Information)
End If
If d.Checked Then
MsgBox("The difference of the numbers " & num1 & " and
" & num2 & " is " & num1 - num2 & ".", MsgBoxStyle.Information)
End If
If m.Checked Then
MsgBox("The multiple of the numbers " & num1 & " and " & num2 & " is " & num1 * num2 & ".", MsgBoxStyle.Information)
End If
If q.Checked Then
MsgBox("The quotient of the numbers " & num1 & " and " & num2 & " is " & num1 / num2 & ".", MsgBoxStyle.Information)
End If
End If
If reverse.Checked = True Then
If s.Checked Then
MsgBox("The sum of the numbers " & num1 & " and " & num2 & "
is " & num2 + num1 & ".", MsgBoxStyle.Information)
End If
If d.Checked Then
MsgBox("The difference of the numbers " & num1 & " and
" & num2 & " is " & num2 - num1 & ".", MsgBoxStyle.Information)
End If
If m.Checked Then
MsgBox("The multiple of the numbers " & num1 & " and " & num2 & " is " & num2 * num1 & ".", MsgBoxStyle.Information)
End If
If q.Checked Then
MsgBox("The quotient of the numbers " & num1 & " and " & num2 & " is " & num2 / num1 & ".", MsgBoxStyle.Information)
End If
End If
If (s.Checked = False) And (d.Checked = False) And (m.Checked = False) And (q.Checked = False) Then
MsgBox("No operation key has been selected. Please try

again.",
MsgBoxStyle.Exclamation, "Calculator")
End If
End Sub

'End of code
'*******************************
"Peter Proost" wrote:

> when do you place the entered values in the double variables?
>
> I propbably wont be able to reply anymore untill tomorrow
>
> grtz peter
>
> "Xero" <jeff@chezjeff(REMOVE).net> wrote in message
> news:F9**********************************@microsof t.com...
> > Yes, it is.
> >
> > "Peter Proost" wrote:
> >
> > > is it a windows forms application?
> > >
> > > grtz Peter
> > >
> > >
> > > "Xero" <jeff@chezjeff(REMOVE).net> wrote in message
> > > news:D9**********************************@microsof t.com...
> > > > Sorry but they don't work either.
> > > > The code 'num1.Text' is underlined by a blue line, saying that

'Text
> is
> > > not
> > > > a member of Double.'
> > > > Sorry that I forgot to tell you that both num1 and num2 are of

data
> type
> > > > 'Double'.
> > > >
> > > > "Peter Proost" wrote:
> > > >
> > > > > Here are 2 possible pieces of code, place it behind the click ev ent
> of a
> > > > > button, or where you want to check the textboxes
> > > > >
> > > > > <<<<<<<code 1>>>>>>
> > > > >
> > > > > If Not IsNumeric(num1.Text) Or Not IsNumeric(num2.Text) Then
> > > > > MsgBox("one of the boxes is empty")
> > > > > End If
> > > > >
> > > > > <<<<<<code 1>>>>>>
> > > > >
> > > > > <<<<<<code 2>>>>>>
> > > > >
> > > > > Dim blnOk As Boolean
> > > > > If Not IsNumeric(num1.Text) Then
> > > > > blnOk = False
> > > > > MsgBox("Box one is empty")
> > > > > Else
> > > > > blnOk = True
> > > > > End If
> > > > > If Not IsNumeric(num2.Text) Then
> > > > > blnOk = False
> > > > > MsgBox("Box two is empty")
> > > > > Else
> > > > > blnOk = True
> > > > > End If
> > > > >
> > > > > If blnOk Then
> > > > > 'execute the rest of the code
> > > > > MsgBox("They're both filled")
> > > > > End If
> > > > >
> > > > > <<<<<<code 2>>>>>>>>
> > > > >
> > > > > greetz Peter
> > > > >
> > > > >
> > > > >
> > > > > "Xero" <jeff@chezjeff(REMOVE).net> wrote in message
> > > > > news:C0**********************************@microsof t.com...
> > > > > > Eh ... sorry, I still have some problem ...
> > > > > > I copied the line of code but it didn't work out.
> > > > > >
> > > > > > Could you post the exact line of code? I want to display
the > message
> > > 'One
> > > > > of
> > > > > > the boxes is empty.' if any of the two boxes named as 'num1' and
> > > 'num2' is
> > > > > > left empty. Thanks again.
> > > > > >
> > > > > > "Peter Proost" wrote:
> > > > > >
> > > > > > > Hi,
> > > > > > >
> > > > > > > check if isnumeric(textbox.text)
> > > > > > > or for the length you could check textbox.text.length >

0 > > > > > > > or combine them
> > > > > > >
> > > > > > > hth
> > > > > > > Peter
> > > > > > > "Xero" <jeff@chezjeff(REMOVE).net> wrote in message
> > > > > > > news:F8**********************************@microsof t.com... > > > > > > > > Hello. I am using Visual Studio .NET (Academic Edition) to > write a
> > > VB
> > > > > > > > program. My computer is running Win XP Pro.
> > > > > > > >
> > > > > > > > I am writing a calculator and requires users to enter two > numbers.
> > > > > After
> > > > > > > > entering the numbers, they should click a button called > 'Display
> > > > > Results'.
> > > > > > > > How can I display a dialog box prompting the users to

check
> their
> > > > > entry if
> > > > > > > > they left any of the boxes empty? I have tried the ..IsNaN > function
> > > but
> > > > > in
> > > > > > > > vein.
> > > > > > > >
> > > > > > > > Thanks.
> > > > > > > > --
> > > > > > > > Xero
> > > > > > > >
> > > > > > > > http://www.chezjeff.net
> > > > > > > > My personal web portal
> > > > > > >
> > > > > > >
> > > > > > >
> > > > >
> > > > >
> > > > >
> > >
> > >
> > >
>
>
>


Nov 21 '05 #14
Hi. The code does the trick. Thanks very very much.

Xero
"Peter Proost" wrote:
place num1 = cdbl(TextBox1.Text) and num2 = cdbl(TextBox2.Text) instead of
num1 = TextBox1.Text and num2 = TextBox2.Text, you probably have option
strict on that's what generates the error.

this piece of code I tested and works just fine:

<<<<<<code>>>>>>>
Dim num1 As Double
Dim num2 As Double
Dim blnOk As Boolean = True

If Not IsNumeric(TextBox1.Text) Then
blnOk = False
MsgBox("Box one is empty")
Else
num1 = CDbl(TextBox1.Text)
blnOk = True
End If

If Not IsNumeric(TextBox2.Text) Then
blnOk = False
MsgBox("Box two is empty")
Else
num2 = CDbl(TextBox2.Text)
blnOk = True
End If

<<<<<<code>>>>>>

greetz Peter

"Xero" <jeff@chezjeff(REMOVE).net> wrote in message
news:70**********************************@microsof t.com...
It won't work either ...
An error box containing the following message appeared:
An unhandled exception of type 'System.InvalidCastException' occurred in
microsoft.visualbasic.dll

Additional information: Cast from string "" to type 'Double' is not valid.
"Peter Proost" wrote:
Hi, this code should do the trick

<<<<<<<<<<code>>>>>>>>>>>>

Dim num1 As Double
Dim num2 As Double
Dim blnOk As Boolean = True
If Not IsNumeric(TextBox1.Text) Then
blnOk = False
MsgBox("Box one is empty")
Else
num1 = TextBox1.Text
blnOk = True
End If
If Not IsNumeric(TextBox2.Text) Then
blnOk = False
MsgBox("Box two is empty")
Else
num2 = TextBox2.Text
blnOk = True
End If

If blnOk Then
If reverse.Checked = False Then
If s.Checked Then
MsgBox("The sum of the numbers " & num1 & " and " & num2 & " is " & num1 + num2 & ".", MsgBoxStyle.Information)
End If
If d.Checked Then
MsgBox("The difference of the numbers " & num1 & " and " & num2 & " is " & num1 - num2 & ".", MsgBoxStyle.Information)
End If
If m.Checked Then
MsgBox("The multiple of the numbers " & num1 & " and " & num2 & " is " & num1 * num2 & ".", MsgBoxStyle.Information)
End If
If q.Checked Then
MsgBox("The quotient of the numbers " & num1 & " and " & num2 & " is " & num1 / num2 & ".", MsgBoxStyle.Information)
End If
End If
If reverse.Checked = True Then
If s.Checked Then
MsgBox("The sum of the numbers " & num1 & " and " & num2 & " is " & num2 + num1 & ".", MsgBoxStyle.Information)
End If
If d.Checked Then
MsgBox("The difference of the numbers " & num1 & " and " & num2 & " is " & num2 - num1 & ".", MsgBoxStyle.Information)
End If
If m.Checked Then
MsgBox("The multiple of the numbers " & num1 & " and " & num2 & " is " & num2 * num1 & ".", MsgBoxStyle.Information)
End If
If q.Checked Then
MsgBox("The quotient of the numbers " & num1 & " and " & num2 & " is " & num2 / num1 & ".", MsgBoxStyle.Information)
End If
End If
If (s.Checked = False) And (d.Checked = False) And (m.Checked = False) And (q.Checked = False) Then
MsgBox("No operation key has been selected. Please try
again.", MsgBoxStyle.Exclamation, "Calculator")
End If
End If

<<<<<<<<<code>>>>>>>>

greetz Peter
"Xero" <jeff@chezjeff(REMOVE).net> wrote in message
news:C3**********************************@microsof t.com...
> Perhaps I should post the lines of code of the event handlier the 'Display > Result' button. Thanks again.
>
> '*******************************
> 'Begin of code
>
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles Button1.Click
> Dim num1 As Double
> Dim num2 As Double
> num1 = TextBox1.Text
> num2 = TextBox2.Text
> If reverse.Checked = False Then
> If s.Checked Then
> MsgBox("The sum of the numbers " & num1 & " and " & num2 & "
> is " & num1 + num2 & ".", MsgBoxStyle.Information)
> End If
> If d.Checked Then
> MsgBox("The difference of the numbers " & num1 & " and " & > num2 & " is " & num1 - num2 & ".", MsgBoxStyle.Information)
> End If
> If m.Checked Then
> MsgBox("The multiple of the numbers " & num1 & " and " & > num2 & " is " & num1 * num2 & ".", MsgBoxStyle.Information)
> End If
> If q.Checked Then
> MsgBox("The quotient of the numbers " & num1 & " and " & > num2 & " is " & num1 / num2 & ".", MsgBoxStyle.Information)
> End If
> End If
> If reverse.Checked = True Then
> If s.Checked Then
> MsgBox("The sum of the numbers " & num1 & " and " & num2 & "
> is " & num2 + num1 & ".", MsgBoxStyle.Information)
> End If
> If d.Checked Then
> MsgBox("The difference of the numbers " & num1 & " and " & > num2 & " is " & num2 - num1 & ".", MsgBoxStyle.Information)
> End If
> If m.Checked Then
> MsgBox("The multiple of the numbers " & num1 & " and " & > num2 & " is " & num2 * num1 & ".", MsgBoxStyle.Information)
> End If
> If q.Checked Then
> MsgBox("The quotient of the numbers " & num1 & " and " & > num2 & " is " & num2 / num1 & ".", MsgBoxStyle.Information)
> End If
> End If
> If (s.Checked = False) And (d.Checked = False) And (m.Checked = > False) And (q.Checked = False) Then
> MsgBox("No operation key has been selected. Please try
again.",
> MsgBoxStyle.Exclamation, "Calculator")
> End If
> End Sub
>
> 'End of code
> '*******************************
>
>
> "Peter Proost" wrote:
>
> > when do you place the entered values in the double variables?
> >
> > I propbably wont be able to reply anymore untill tomorrow
> >
> > grtz peter
> >
> > "Xero" <jeff@chezjeff(REMOVE).net> wrote in message
> > news:F9**********************************@microsof t.com...
> > > Yes, it is.
> > >
> > > "Peter Proost" wrote:
> > >
> > > > is it a windows forms application?
> > > >
> > > > grtz Peter
> > > >
> > > >
> > > > "Xero" <jeff@chezjeff(REMOVE).net> wrote in message
> > > > news:D9**********************************@microsof t.com...
> > > > > Sorry but they don't work either.
> > > > > The code 'num1.Text' is underlined by a blue line, saying that
'Text
> > is
> > > > not
> > > > > a member of Double.'
> > > > > Sorry that I forgot to tell you that both num1 and num2 are of
data
> > type
> > > > > 'Double'.
> > > > >
> > > > > "Peter Proost" wrote:
> > > > >
> > > > > > Here are 2 possible pieces of code, place it behind the click ev ent
> > of a
> > > > > > button, or where you want to check the textboxes
> > > > > >
> > > > > > <<<<<<<code 1>>>>>>
> > > > > >
> > > > > > If Not IsNumeric(num1.Text) Or Not IsNumeric(num2.Text) Then
> > > > > > MsgBox("one of the boxes is empty")
> > > > > > End If
> > > > > >
> > > > > > <<<<<<code 1>>>>>>
> > > > > >
> > > > > > <<<<<<code 2>>>>>>
> > > > > >
> > > > > > Dim blnOk As Boolean
> > > > > > If Not IsNumeric(num1.Text) Then
> > > > > > blnOk = False
> > > > > > MsgBox("Box one is empty")
> > > > > > Else
> > > > > > blnOk = True
> > > > > > End If
> > > > > > If Not IsNumeric(num2.Text) Then
> > > > > > blnOk = False
> > > > > > MsgBox("Box two is empty")
> > > > > > Else
> > > > > > blnOk = True
> > > > > > End If
> > > > > >
> > > > > > If blnOk Then
> > > > > > 'execute the rest of the code
> > > > > > MsgBox("They're both filled")
> > > > > > End If
> > > > > >
> > > > > > <<<<<<code 2>>>>>>>>
> > > > > >
> > > > > > greetz Peter
> > > > > >
> > > > > >
> > > > > >
> > > > > > "Xero" <jeff@chezjeff(REMOVE).net> wrote in message
> > > > > > news:C0**********************************@microsof t.com...
> > > > > > > Eh ... sorry, I still have some problem ...
> > > > > > > I copied the line of code but it didn't work out.
> > > > > > >
> > > > > > > Could you post the exact line of code? I want to display the > > message
> > > > 'One
> > > > > > of
> > > > > > > the boxes is empty.' if any of the two boxes named as 'num1' and
> > > > 'num2' is
> > > > > > > left empty. Thanks again.
> > > > > > >
> > > > > > > "Peter Proost" wrote:
> > > > > > >
> > > > > > > > Hi,
> > > > > > > >
> > > > > > > > check if isnumeric(textbox.text)
> > > > > > > > or for the length you could check textbox.text.length > 0 > > > > > > > > or combine them
> > > > > > > >
> > > > > > > > hth
> > > > > > > > Peter
> > > > > > > > "Xero" <jeff@chezjeff(REMOVE).net> wrote in message
> > > > > > > > news:F8**********************************@microsof t.com... > > > > > > > > > Hello. I am using Visual Studio .NET (Academic Edition) to > > write a
> > > > VB
> > > > > > > > > program. My computer is running Win XP Pro.
> > > > > > > > >
> > > > > > > > > I am writing a calculator and requires users to enter two > > numbers.
> > > > > > After
> > > > > > > > > entering the numbers, they should click a button called > > 'Display
> > > > > > Results'.
> > > > > > > > > How can I display a dialog box prompting the users to
check
> > their
> > > > > > entry if
> > > > > > > > > they left any of the boxes empty? I have tried the ..IsNaN > > function
> > > > but
> > > > > > in
> > > > > > > > > vein.
> > > > > > > > >
> > > > > > > > > Thanks.
> > > > > > > > > --
> > > > > > > > > Xero
> > > > > > > > >
> > > > > > > > > http://www.chezjeff.net
> > > > > > > > > My personal web portal
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > >
> > > >
> > > >
> >
> >
> >


Nov 21 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Glyphman | last post by:
I have a bunch of pages with long forms, with lots of input types-text, radios, textareas, and the debugging process has become overwhelming. What I need to happen is to make sure that 1. Every...
12
by: Ritz, Bruno | last post by:
hi in java i found that when a method has a throws clause in the definition, callers must either handle the exceptions thrown by the method they are calling or "forward" the exception to the...
4
by: John Fereira | last post by:
So, one of the limitations of multipart-form handling is that when an <input type="file" ..> tag is used it will bring up a window which allows a user to select a file for upload but won't allow...
5
by: Krechting | last post by:
Hi ALl, I have a code that checks if the documents in a hyperlink field are still where they should be. I use fileexist(). First I want to filter out all the hyperlink fields that are empty. I...
11
by: wolfesimon | last post by:
I have a form where the user copies a handwritten contract into a text field "Contract1". The contract usually exeeds 255 characters. Therefore I provided "Contract2", "Contract3", and "Contract4"...
7
by: Dabbler | last post by:
I'm using an ObjectDataSource with a stored procedure and am getting the following error when trying to update (ExecuteNonQuery): System.Data.SqlClient.SqlException: Procedure or Function...
5
by: wendyzhakata | last post by:
you are required to keep tailoring records of fellow students in your class. each record is made up of the following fields: (a)Fname: a character array of maximum15 characters representing the...
3
by: Christopher Mocock | last post by:
Hi all, Bit of a python newbie so need a little help with a CGI script I'm trying to write. I've got it working fine as long as the fields of the form are filled in correctly, however I need to...
3
by: GazK | last post by:
I am hoping someone can steer me towards an elegant solution to a simple problem. I have a query result which returns an array of details about a physical building, including its address. The...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.