Quantcast
Channel: Grasshopper - McNeel Forum
Viewing all articles
Browse latest Browse all 39494

Problem with a function in VB.net component

$
0
0

@JesseOgburn wrote:

Hi,
I am working to create a VB.net component that can take a text list of parameters and read values from that file. I want to then use those values to run the rest of my definition.
I can’t seem to get the function to work for some reason. I’ve gone over it with as minutely as I can and completely rewrote it thinking perhaps that a different structure would somehow eliminate the problem.
Is there something I’m overlooking or is there just a completely better way to do this(I have no doubt there is!)

Much thanks for any input…

Here is my code from the VB.net component and the necessary files

Private Sub RunScript(ByVal x As List(Of Object), ByRef A As Object, ByRef B As Object) 

    A = GetValue(21, x)


  End Sub 

  '<Custom additional code> 
  
  Function GetValue(lineNumber As String, paramList As List(Of Object)) As String
    
    Dim parameter As String = ""
       
    
    For Each i As String In paramList
         
      Dim line As String
      Dim number As String
      Dim commaLocation As Integer
      Dim equalsLocation As Integer
      
      ' put the line into a variable
      line = paramList(i)
      
      ' get the location of the comma and equals sign
      commaLocation = line.IndexOf(",")
      equalsLocation = line.IndexOf("=")
      
      ' put the line number into a variable
      number = line.Substring(0, commaLocation - 1)
      
      If lineNumber = number Then
    
        ' put the parameter into a variable
        parameter = line.Substring(equalsLocation + 1)
        
      End If    
      
    Next
    
    Return parameter 
    
  End Function
    
  '</Custom additional code> 
End Class

testcomponent.txt (64 Bytes)

Component Try 2.gh (19.3 KB)

Posts: 8

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 39494

Trending Articles