how to call a function procedue?

Page 1 of 1

4 Replies - 2277 Views - Last Post: 20 October 2009 - 04:21 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=132715&amp;s=6ea4250582f9dbd9761cd054704a331e&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

#1 cron7

Reputation: 0
• Posts: 11
• Joined: 16-October 09

how to call a function procedue?

Posted 17 October 2009 - 11:45 PM

How to call a function procedue which consists of array, integer variables in the main sub?

Function Calcost(route(), v(), c, num, p As Integer)
.................
End Function

Thanks
Is This A Good Question/Topic? 0

Replies To: how to call a function procedue?

#2 bytelogik

Reputation: 22
• Posts: 218
• Joined: 06-October 09

Re: how to call a function procedue?

Posted 18 October 2009 - 12:10 AM

Try this:

Dim arRoute(1)
Dim v(1)

arRoute(0) = "route 1"
arRoute(1) = "route 2"
v(0) = 100
v(1) = 200
ArFunction arRoute, v, 1, 2, 3

End Sub
Sub ArFunction(route(), v(), c, num, p As Integer)
MsgBox route(0)
MsgBox v(0)
End Sub

Hope this helps.

#3 cron7

Reputation: 0
• Posts: 11
• Joined: 16-October 09

Re: how to call a function procedue?

Posted 18 October 2009 - 02:01 AM

in the main sub,
I declare 2-D array for route:
Dim route(20, 20) As Integer
if I want to write a function that needs the values of route(20,20)
then how to write (the arguments) ?

Function Calcost(???????)
.................
End Function

#4 bytelogik

Reputation: 22
• Posts: 218
• Joined: 06-October 09

Re: how to call a function procedue?

Posted 18 October 2009 - 09:41 PM

Well, you can retreive the values of the array item before sending it to the function.
For example:

In the main sub:

Location=route(20,20)
Calcost Location 'call the function

In the function:

Function Calcost(ByVal Loc as Long) 'change the data type with yours
'Use the Loc into calculation
End Function

Can you can be more specific about how you are using the algorithm for calculation?

keep smiling.

#5 zhanfeng

Reputation: 6
• Posts: 75
• Joined: 09-November 08

Re: how to call a function procedue?

Posted 20 October 2009 - 04:21 PM

I believe you can declare the parameter as a 1D array and pass a 2D array. I could be wrong since I have not touched VB for a while now.