Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: TheNewOne on June 19, 2004, 01:48 AM

Title: ParamArray Usage?
Post by: TheNewOne on June 19, 2004, 01:48 AM
Does anyone know how to use ParamArray that can help me learn how to use it. Ive tried msdn and i couldnt recollect enough from it to actually use it. Any help is greatly appreciated.
Title: Re:ParamArray Usage?
Post by: Lenny on June 19, 2004, 02:00 AM
You should also try Google.........
http://www.vb-helper.com/howto_param_array.html

Its purpose is just as it sounds, an array of parameters...If you wanted to send a dynamic number arguments you use paramarray.

This is frequently used in the addChat function of most bots...
It allows you to:
rtbadd "Text1", color1

and also use the same method to do:
rtbadd "Text1", color1, "Text2", color2
etc...


rtbadd Function:

Public Sub rtbAdd(ParamArray Elements() As Variant)
  Dim i as Integer
  For i = LBound(Elements) To UBound(Elements) Step 2  'Two seaparate Parameters (Text, Color)
     With SomeRtb
        .SelStart = Len(.text)
        .SelLength = 0
        .SelColor = Elements(i + 1) 'Color
        .SelText = Elements(i) 'Text
        .SelStart = Len(.text)
     End With
  Next i
End Sub