Please Tell Me How to specify the parameter.

C

Chuck Insight

When I run the code below, I get
Compiler Error Message: Argument not specified for parameter 'key' of 'Public Shared Sub Add(key As Object, value As Object)'.

Here's the code:

<%@Page Explicit = "True" Language="VB" Debug="True" %>
<HTML><HEAD>
<Script runat="server">
Sub OK_Button(Sender As Object, E As Eventargs)
end sub

Public Shared Sub Add(ByVal key As Object, ByVal value As Object)
Static usethis as arraylist = new arraylist
dim s as integer
for s = 1 to 50
s += 1
usethis.add(s.ToString)
next s
Static samples as hashtable = new hashtable
dim i as integer
dim up as integer = 0
randomize
dim bh as integer = int(rnd * 50) + 1
for i = 1 to 50
on error resume next
if bh = 1 and usethis.contains(bh) then
up += 1
samples.add(up.ToString, bh.ToString)
usethis.remove("1")
end if
next i
End Sub
</Script></head><BODY>
<%=add.samples.get("1") %>
</BODY></HTML>
 
B

Bob Lehmann

Did the answers in your previous post not answer your question?
The error message is pretty clear about the problem.

you're doing something like this...
Add()

instead of this
Add(keyObject, valueObject)

Bob Lehmann

When I run the code below, I get
Compiler Error Message: Argument not specified for parameter 'key' of
'Public Shared Sub Add(key As Object, value As Object)'.

Here's the code:

<%@Page Explicit = "True" Language="VB" Debug="True" %>
<HTML><HEAD>
<Script runat="server">
Sub OK_Button(Sender As Object, E As Eventargs)
end sub

Public Shared Sub Add(ByVal key As Object, ByVal value As Object)
Static usethis as arraylist = new arraylist
dim s as integer
for s = 1 to 50
s += 1
usethis.add(s.ToString)
next s
Static samples as hashtable = new hashtable
dim i as integer
dim up as integer = 0
randomize
dim bh as integer = int(rnd * 50) + 1
for i = 1 to 50
on error resume next
if bh = 1 and usethis.contains(bh) then
up += 1
samples.add(up.ToString, bh.ToString)
usethis.remove("1")
end if
next i
End Sub
</Script></head><BODY>
<%=add.samples.get("1") %>
</BODY></HTML>
 
C

Chuck Insight

Hi Bob,
First, thanks for taking the time to respond. Unfortunately, I'm still too
much of a rookie to grasp what you're trying to teach me by your suggestion.
The "add" code I wrote seems to follow your example - it is:
samples.add(up.ToString, bh.ToString)
Since this is not correct, will you please be more specific.
Thanks, Chuck
 
B

Bob Lehmann

usethis.add(s.ToString)
This is probably the problem. It's line 5 in your Sub.

Bob Lehmann
 
M

Mythran

Bob Lehmann said:
This is probably the problem. It's line 5 in your Sub.

Bob Lehmann

I could have sworn it was the following to be the problem:

<%=add.samples.get("1") %>

How does that work?

Mythran
 
B

Bob Lehmann

I think you're right. I didn't notice that usethis was a new arraylist - I
just looked at the .add part.

Bob Lehmann
 
C

Chuck Insight

Hi Mythran,
Something along the lines of <%=add.samples.get("1") %> is code I used in
another applications to display items of an array. It is the only way I know
to specify exactly where values populate columns and rows of a table.
However, this project calls for displaying items from a hashtable.

I eventually cajoled the sub to compile without an error. But when I added
the code intended to display the value whatever was in index position #1 of
the samples hashtable, I got the error. Thus, indeed,
<%=add.samples.get("1") %> is the problem.

Now what?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top