:( i have tried by all means but i stil cant code it correctly. pls help!
how do i code and call a sub procedure that retrieves 3numbers frm a comma seperated string,eg."30,15,66" then send the string to convert as a parameter & return the 3 numbers using parameters.
my coding has been incorrect. help needed

8 Years
Discussion Span
Last Post by Teme64

You send the string as a ByVal parameter and get result as ByRef parameters. Use Split function to separate numbers (integers in this case).

Here is a sample:

Private Sub Splitter(ByVal InputStr As String, ByRef Num1 As Integer, ByRef Num2 As Integer, ByRef Num3 As Integer)
Dim SplittedArr() As String

  SplittedArr = Split(InputStr, ",")
  Num1 = CInt(SplittedArr(0))
  Num2 = CInt(SplittedArr(1))
  Num3 = CInt(SplittedArr(2))

End Sub

Private Sub Form_Load()
Dim Num1 As Integer
Dim Num2 As Integer
Dim Num3 As Integer

  Splitter "30,15,66", Num1, Num2, Num3
  MsgBox "Num1=" & Num1 & " Num2=" & Num2 & " Num3=" & Num3, vbOKOnly, "Splitter"
End Sub

If you need decimal numbers, change Integer->Double and CInt->CDbl. Because this was just an example, there's no error checking for the InputStr (number of integers, numeric type etc.)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.