473,405 Members | 2,176 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,405 software developers and data experts.

Call Statement Difficulty???

Private Sub cmdCalculate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdCalculate.Click
If txtName.Text <> "" Then
If txtUnits.Text <> "" Then
If optOne.Checked Or optTwo.Checked Or optThree.Checked
Or optFour.Checked Then
'Data fine
Else
MessageBox.Show("Please choos an option button")
End If
Else
MessageBox.Show("txtUnits")
txtUnits.Focus()
End If
Else
MessageBox.Show("txtName")
txtName.Focus()
End If
End Sub

Private Sub cmdO_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cmdO.Click
Call cmdCalculate_Click()
End Sub

I have the two functions as stated above; now the call statement returns
the error:
C:\vbNet\beginning\nested_if\Form1.vb(141): Argument not specified for
parameter 'e' of 'Private Sub cmdCalculate_Click(sender As Object, e As
System.EventArgs)'.

PLS HELP

THANX

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #1
6 2100
Radith Silva wrote:
Private Sub cmdCalculate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdCalculate.Click

Call cmdCalculate_Click()

I have the two functions as stated above; now the call statement returns
the error:
C:\vbNet\beginning\nested_if\Form1.vb(141): Argument not specified for
parameter 'e' of 'Private Sub cmdCalculate_Click(sender As Object, e As
System.EventArgs)'.


yea well, you omitted both parameters for cmdCalculate_Click. Obviosuly,
that is wrong.
Try

\\\
cmdCalculate_Click(Nothing, Nothing)
///

btw: why do you write "Call"?

--
Konrad -
http://madrat.net/
Nov 20 '05 #2
"Radith Silva" <ra****@xtra.co.nz> schrieb
Private Sub cmdCalculate_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles cmdCalculate.Click
If txtName.Text <> "" Then
If txtUnits.Text <> "" Then
If optOne.Checked Or optTwo.Checked Or
optThree.Checked
Or optFour.Checked Then
'Data fine
Else
MessageBox.Show("Please choos an option
button")
End If
Else
MessageBox.Show("txtUnits")
txtUnits.Focus()
End If
Else
MessageBox.Show("txtName")
txtName.Focus()
End If
End Sub

Private Sub cmdO_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cmdO.Click
Call cmdCalculate_Click()
End Sub

I have the two functions as stated above; now the call statement
returns the error:
C:\vbNet\beginning\nested_if\Form1.vb(141): Argument not specified
for parameter 'e' of 'Private Sub cmdCalculate_Click(sender As
Object, e As System.EventArgs)'.

Better approach (IMO):

private sub Calculate()
If txtName.Text <> "" Then
If txtUnits.Text <> "" Then
If optOne.Checked Or optTwo.Checked Or optThree.Checked Or
optFour.Checked Then
'Data fine
Else
MessageBox.Show("Please choos an option button")
End If
Else
MessageBox.Show("txtUnits")
txtUnits.Focus()
End If
Else
MessageBox.Show("txtName")
txtName.Focus()
End If
end sub

Private Sub cmdCalculate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdCalculate.Click
Calculate()
end sub

Private Sub cmdO_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles cmdO.Click
Calculate
End Sub
- OR -

Delete Sub cmdO_Click and have Sub cmdCalculate_Click handle the click of
both controls:

Private Sub cmdCalculate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdCalculate.Click, cmdO.Click

Notice the 2nd event after "Handles".
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
Nov 20 '05 #3
"Radith Silva" <ra****@xtra.co.nz> schrieb
Private Sub cmdCalculate_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles cmdCalculate.Click
If txtName.Text <> "" Then
If txtUnits.Text <> "" Then
If optOne.Checked Or optTwo.Checked Or
optThree.Checked
Or optFour.Checked Then
'Data fine
Else
MessageBox.Show("Please choos an option
button")
End If
Else
MessageBox.Show("txtUnits")
txtUnits.Focus()
End If
Else
MessageBox.Show("txtName")
txtName.Focus()
End If
End Sub

Private Sub cmdO_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cmdO.Click
Call cmdCalculate_Click()
End Sub

I have the two functions as stated above; now the call statement
returns the error:
C:\vbNet\beginning\nested_if\Form1.vb(141): Argument not specified
for parameter 'e' of 'Private Sub cmdCalculate_Click(sender As
Object, e As System.EventArgs)'.

Better approach (IMO):

private sub Calculate()
If txtName.Text <> "" Then
If txtUnits.Text <> "" Then
If optOne.Checked Or optTwo.Checked Or optThree.Checked Or
optFour.Checked Then
'Data fine
Else
MessageBox.Show("Please choos an option button")
End If
Else
MessageBox.Show("txtUnits")
txtUnits.Focus()
End If
Else
MessageBox.Show("txtName")
txtName.Focus()
End If
end sub

Private Sub cmdCalculate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdCalculate.Click
Calculate()
end sub

Private Sub cmdO_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles cmdO.Click
Calculate
End Sub
- OR -

Delete Sub cmdO_Click and have Sub cmdCalculate_Click handle the click of
both controls:

Private Sub cmdCalculate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdCalculate.Click, cmdO.Click

Notice the 2nd event after "Handles".
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
Nov 20 '05 #4
Radith,
In addition to the other's comments, you can also use Button.PerformClick.
Private Sub cmdO_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cmdO.Click
cmdCalculate.PerformClick()
End Sub
This way if you have multiple handlers for a given button, then all the
handlers will be invoked.

Although I prefer to use Armin's first example. I normally have a single
handler both handle the same event.

Remember VB.NET event model is not your VB6 event model! You can have
multiple handlers for a given event, plus a given event handler can handle
events from multiple objects.

Notice in the following "Button_Click" handles the click event for all three
buttons, while each button also has their own specific handler. This would
be handy if you have some common logic that needed to occur for every click,
plus some specific logic for every click. Or the buttons occur in the base
form and the base form wants to handle the events, plus the derived form
wants to handle the events...

Private WithEvents Button1 As Button
Private WithEvents Button2 As Button
Private WithEvents Button3 As Button
Private Sub Button_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click, Button2.Click, Button3.Click
End Sub Private Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
End Sub Private Sub Button2_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button2.Click
End Sub Private Sub Button3_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button3.Click
End Sub
Hope this helps
Jay

"Radith Silva" <ra****@xtra.co.nz> wrote in message
news:eB**************@TK2MSFTNGP12.phx.gbl... Private Sub cmdCalculate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdCalculate.Click
If txtName.Text <> "" Then
If txtUnits.Text <> "" Then
If optOne.Checked Or optTwo.Checked Or optThree.Checked
Or optFour.Checked Then
'Data fine
Else
MessageBox.Show("Please choos an option button")
End If
Else
MessageBox.Show("txtUnits")
txtUnits.Focus()
End If
Else
MessageBox.Show("txtName")
txtName.Focus()
End If
End Sub

Private Sub cmdO_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cmdO.Click
Call cmdCalculate_Click()
End Sub

I have the two functions as stated above; now the call statement returns
the error:
C:\vbNet\beginning\nested_if\Form1.vb(141): Argument not specified for
parameter 'e' of 'Private Sub cmdCalculate_Click(sender As Object, e As
System.EventArgs)'.

PLS HELP

THANX

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #5
* "Konrad L. M. Rudolph" <ko************@madrat.net> scripsit:
yea well, you omitted both parameters for
cmdCalculate_Click. Obviosuly, that is wrong.

Try

\\\
cmdCalculate_Click(Nothing, Nothing)
///

btw: why do you write "Call"?


I would call the button's 'PerformClick' method. Instead of passing
'Nothing', you should pass a reference to the button in the 1st
parameter and 'EventArgs.Empty' in the 2nd parameter.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #6
Hi Radith,

A lot of answers mostly on click events, I give another approach however
more with the point to show you the purpose of the OrElse operator.

I also give another method for that click event (Keep in mind there is no
best and there are much more methods).

Private Sub cmdCalculate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdCalculate.Click
If txtName.Text <> "" Then
If txtUnits.Text <> "" Then
If optOne.Checked OrElse optTwo.Checked OrElse
optThree.Checked

The OrElse stops evaluating when the condition is True.

OrElse optFour.Checked Then
'Data fine
Else
MessageBox.Show("Please choos an option button")
End If
Else
MessageBox.Show("txtUnits")
txtUnits.Focus()
End If
Else
MessageBox.Show("txtName")
txtName.Focus()
End If
End Sub

Private Sub cmdO_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cmdO.Click
cmdCalculate_Click(sender, e) 'Only when the signatures are equal
as in this case
End Sub

Nov 20 '05 #7

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

Similar topics

5
by: Alex | last post by:
I am having difficulty writing a SQL statement and I was wondering if one of you gurus could help me. I have a table that has three fields: InvoiceID, Item, ItemPrice. Each InvoiceID is associated...
0
by: Kid A | last post by:
I am writing stored proecdures on Oracle 9 (release 1 I believe). I am having difficulty creating a stored procedure that makes a remote function call to a database on a different host. On the...
8
by: Adam Nemitoff | last post by:
Is is possible to construct a SELECT statement that contains a WHERE clause that uses the value from a column in the "next" row? ie. given a table with a single field named "myField" with the...
22
by: Marc Mones | last post by:
Hello, I'working with IBM DB2 V8.1 and CLI/ODBC. I've got a problem with the following statement: ******************************************************************************** SELECT...
6
by: mygoogleaccount | last post by:
Hi, may be someone could help me ? i need to use cyrillic letters in a php application. I changed everything to UTF-8 and it works fine. The only problem are CYRILLIC SMALL LETTER ES...
16
by: arne | last post by:
Hi all, imagine I call a function, but omit one of the parameters, like: foo.c: void foo( int a, int b ) { /* do something with a and b */ return; }
2
by: savio XCIX | last post by:
I created the following stored procedure: ======= CREATE PROCEDURE TBLNAME.proc_test (IN p_custnum VARCHAR(8), IN p_zipcode...
0
BenRatcliffe
by: BenRatcliffe | last post by:
Hi there, I was wondering if anyone could help me. I have a comlpex database with a number of forms that have data entered on them and then saved into the correct table etc. In this instance I am...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...

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.