4 Replies - 1830 Views - Last Post: 20 October 2009 - 04:21 PM Rate Topic: -----

#1 cron7  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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  Icon User is offline

  • D.I.C Head

Reputation: 22
  • View blog
  • Posts: 212
  • Joined: 06-October 09

Re: how to call a function procedue?

Posted 18 October 2009 - 12:10 AM

Try this:

Private Sub Form_Load()
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.
Was This Post Helpful? 0
  • +
  • -

#3 cron7  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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
Was This Post Helpful? 0
  • +
  • -

#4 bytelogik  Icon User is offline

  • D.I.C Head

Reputation: 22
  • View blog
  • Posts: 212
  • 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.
Was This Post Helpful? 0
  • +
  • -

#5 zhanfeng  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • 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.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1