Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Win API / September 2008



Tip: Looking for answers? Try searching our database.

convert streamreader line to system.drawing.point

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dave Bootsma - 08 Sep 2008 18:18 GMT
I have an application where I want to redraw a polygon from points I
retrieve from a file.
The file is read with streamreader line by line each line contains the
points for each polygon.
Below is a typical line from my file.
500,748 500,678 552,678 552,696 584,696 584,714 612,714 612,748

Each set of x,y coordinates is separated by a space.

How can I read this into my points collection. If I currently try I get
can't convert issues.

Here's code I have been hacking and slashing
       Dim blueBrush As New SolidBrush(Color.Blue)
       Dim curvePoints As Point()
       Dim part As Integer
       Dim part2 As Integer
       Dim pts As Point

       Dim formGraphics2 As System.Drawing.Graphics = Me.CreateGraphics()

       Try
           ' Create an instance of StreamReader to read from a file.
           Using sr As StreamReader = New StreamReader("Polygon.txt")
               Dim line As String
               ' Read and display the lines from the file until the end
               ' of the file is reached.
               Do
                   line = sr.ReadLine()
                   If line <> "" Then
                       part =
Convert.ToInt32(Microsoft.VisualBasic.Left(line, 3))

                       part2 =
Convert.ToInt32(Microsoft.VisualBasic.Mid(line, 5, 3))
                       pts = (part,part2)
                       curvePoints = pts

                   End If

                   'formGraphics2.FillPolygon(blueBrush, curvePoints)
               Loop Until line Is Nothing
               sr.Close()
           End Using
       Catch E As Exception
           ' Let the user know what went wrong.
           Console.WriteLine("The file could not be read:")
           Console.WriteLine(E.Message)
       End Try

please respond via email if possible

Signature

Dave Bootsma
Bradenton Fl.
(941) 224-8298

Ken Halter - 08 Sep 2008 20:39 GMT
> Here's code I have been hacking and slashing
>        Dim blueBrush As New SolidBrush(Color.Blue)

Well, multiposting to VB Classic groups surely won't help. Try a dotNet
group. This group is here to support people attempting to use the Windows
API in VB versions <= 6... iow, even if it *was* a dotNet group, it's not an
API question, so....

Also, multiposting is rude. Use Crossposting instead.

Signature

Ken Halter
Part time groupie

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.