J
Jim Aksel
Appending text between two fields is easy:
dim tsk as task
for each tsk in activeproject.tasks
tsk.Text1=tsk.Text1 & tsk.Text2
next tsk
This code will change the tsk.Text1 to a combination of text1 and text2 for
each task.
Now, move to the next layer of abstraction. I have a form that asks the
user which two fields he wants. So the user may independently select "Name"
and Text24 from two different dop downs...cboSource and cboTakeFrom
So, I end up with a double nested Select Case:
Select Case cboSource.Value
Case "Name"
Select Case cboTakeFrom
Case "Name"
tsk.Name=tsk.Name + tsk.Name
Case "Text1"
tsk.Name = tsk.Name + tsk.Text1
Case "Text2"
tsk.Name=tsk.Name + tsk.Text2
....
End Select (cboTakeFrom)
Case "Text1" (Source is Text1)
Select Case cboTakeFrom
Case "Name"
tsk.Text1=tsk.Text1 + tsk.Name
....
Case "Text30"
tsk.Text1=tsk.Text1+tsk.Text30
End Select (cboTakeFrom)
Case "Text2"
..... (all the text based fields)
End Select
This will be hard to maintain.
What I would like to do is see if there is a different approach where I can
pass the arguments and avoid the double nested Select Case statements.
Something lazy like this:
private myFunction(byRef tsk as task, Source as ??, TakeFrom as ??)
tsk.Source=tsk.Source+tsk.TakeFrom
end function
So my call would look like this:
call myFunction(tsk, tsk.Name, tsk.Text24)
Any ideas? Just trying to avoid the brute force approach with something
having a little more finese.
Jim
dim tsk as task
for each tsk in activeproject.tasks
tsk.Text1=tsk.Text1 & tsk.Text2
next tsk
This code will change the tsk.Text1 to a combination of text1 and text2 for
each task.
Now, move to the next layer of abstraction. I have a form that asks the
user which two fields he wants. So the user may independently select "Name"
and Text24 from two different dop downs...cboSource and cboTakeFrom
So, I end up with a double nested Select Case:
Select Case cboSource.Value
Case "Name"
Select Case cboTakeFrom
Case "Name"
tsk.Name=tsk.Name + tsk.Name
Case "Text1"
tsk.Name = tsk.Name + tsk.Text1
Case "Text2"
tsk.Name=tsk.Name + tsk.Text2
....
End Select (cboTakeFrom)
Case "Text1" (Source is Text1)
Select Case cboTakeFrom
Case "Name"
tsk.Text1=tsk.Text1 + tsk.Name
....
Case "Text30"
tsk.Text1=tsk.Text1+tsk.Text30
End Select (cboTakeFrom)
Case "Text2"
..... (all the text based fields)
End Select
This will be hard to maintain.
What I would like to do is see if there is a different approach where I can
pass the arguments and avoid the double nested Select Case statements.
Something lazy like this:
private myFunction(byRef tsk as task, Source as ??, TakeFrom as ??)
tsk.Source=tsk.Source+tsk.TakeFrom
end function
So my call would look like this:
call myFunction(tsk, tsk.Name, tsk.Text24)
Any ideas? Just trying to avoid the brute force approach with something
having a little more finese.
Jim