Object instead of passing arguments

A

Arne Hegefors

Hi! I have a sub that calls another sub and passes alot of arguments. The
idea is for the main sub to send Strings to the other sub that fills those
strings with data. This works fine but is it possible to use an obect instead
and just pass the object as argument? How would you write that? The problem
is that the number of arguments may become very large and it just seems like
a bad idea to pass eg 20 arguments to a sub? Any help appreciated!

Here is the main sub:
Dim secID As String
Dim strikePrice As String
Dim maturityDate As String
Dim counterParty As String
Dim numberOfUnits As String
Dim optionType As String
Dim excerciseType As String

If sSecurityTypeText = "#FX OPTION" Then
oPosFile.Cells(i, 1).Value = "COMMODITY OPTION"
secID = oPosFile.Cells(i, 3)
Call readFXOptionFile(secID, numberOfUnits,
strikePrice, maturityDate, counterParty, optionType, excerciseType)

and here is the other sub:

Public Sub readFXOptionFile(ID As String, unts As String, strike As String,
matDate As String, cPrt As String, tpe As String, exType As String)
Dim i As Long

ID = Split(ID, "_")(0)
Workbooks.Open "X:\SCD_RiskManager_Pos\RMDBII\test.xls"
Workbooks("test.xls").Activate

Range("A1").Activate
Do Until ActiveCell.Offset(i, 0) = ""
If InStr(CStr(ActiveCell.Offset(i, 0)), ID) > 0 Then 'match ID
unts = ActiveCell.Offset(i, 1) 'assign
data
strike = ActiveCell.Offset(i, 3)
matDate = ActiveCell.Offset(i, 4)
cPrt = ActiveCell.Offset(i, 5) 'fix cells!!!!!!!
tpe = ActiveCell.Offset(i, 5)
exType = ActiveCell.Offset(i, 5)
End If
i = i + 1
Loop
End Sub


Any help most appreciated! Thanks alot!
 

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

Top