string to Point ?!! RRS feed

  • Question

  • User-341609134 posted

    Dear Firends

    dim test as string = "124,215,54,53,85,65,84,54,35,15,26,36,26,21,54,50"
    is it possibel to use this String as pen  to DrawPolygon ?


    Thursday, April 14, 2005 11:29 AM

All replies

  • User1416329745 posted

    Looks like Fibonacci to me but I could be wrong.  You could run into stack overflow exception.  Hope this helps.


    Friday, April 15, 2005 10:16 PM
  • User-865881720 posted

    If I'm correct in my assumption that pairs of  numbers in the comma delimited string represent the verticies of the polygon, this should work (but has not been tested):

    Public Sub DrawPolygonFromString(ByVal p As Pen, ByVal g As Graphics, ByVal s As String)
          Dim strPoints() As String
          Dim n, i, j As Integer

          strPoints = s.Split(","c)
          n = strPoints.Length
          If n Mod 2 <> 0 Then
             Throw New ArgumentException("Comma delimited string must contain an even number of values")
          End If
          n = (n \ 2) - 1
          Dim Points(n) As Point
          For i = 0 To n
                j = i * 2
                Points(i) = New Point(Convert.ToInt32(strPoints(j)), Convert.ToInt32(strPoints(j + 1)))
          g.DrawPolygon(p, Points)
    End Sub

    If by "use this String as pen" you meen that the numbers represent properties of a pen object, that's something entirely different.

    Saturday, April 16, 2005 6:50 AM
  • User-341609134 posted

    dear friend

    thank you very very much


    Monday, April 18, 2005 7:10 AM