Results 1 to 4 of 4

Thread: Errors

  1. #1

    Thread Starter
    New Member yati's Avatar
    Join Date
    Jan 2009
    Location
    Malaysia
    Posts
    5

    Errors

    I am on upgrading from VB6 to VB9, could anyone help me with these errors

    Code:
    Public Sub PlotXY(ByRef X() As Double, ByRef y() As Double, ByRef gtitle As String, ByRef xlabel As String, ByRef ylabel As String, ByRef backClr As String)
    		
    		Dim n As Short
    		Dim yellow, red, blue As Object
    		Dim black, green, white As Object
    		Dim grey As Object
    		Dim bkcolor As Object
    		Dim XZ(10000) As Double
    		Dim YZ(10000) As Double
    		Dim NoIntervx, NoIntervy As Double
    		
    		Dim Ypmin2, Ypmin1, Ypmin3 As Double
    		Dim Ypmax2, Ypmax1, Ypmax3 As Double
    		Dim ypmin, ypmax As Double
    		Dim xformat, yformat As String
    		Dim FtSz As Short
    		Dim WdP, HtP As Double
    		Dim SideLRP1, SideTBP1 As Double
    		Dim xtwmin, ytwmax, ytwmin, xtwmax As Short
    		Dim xpmin, xpmax As Double
    		Dim IdMinx, IdMaxX As Short
    		Dim idminy, Idmaxy As Short
    		Dim i As Integer
    		
    		Dim nplot As Short
    		Dim cx, mx, my_Renamed, cy As Double
    		Dim xlabelx, xint, Yint As Double
    		Dim yp1, xp1, ylabely As Double
    		Dim xp2, yp2 As Double
            Dim k As Short
            Dim pen As Pen
    
     
    
            Form3.Picture1.Visible = True
    
            'User control
            NoIntervx = 5.0# 'no of grid lines
            NoIntervy = 5.0#
            xformat = "##0.000" 'xinterval label
            yformat = "##0.0"
            FtSz = 10 'fontsize
            Form3.Picture1.Font = VB6.FontChangeName(Form3.Picture1.Font, "arial narrow") 'graph font
    
            n = sizeVector(X)
    
            Form3.Visible = True
    
            'if log(x)
            For i = 1 To n
                On Error GoTo xx
                'XZ(I) = X(I)
                'YZ(I) = Y(I)
                XZ(i) = System.Math.Log(X(i)) / System.Math.Log(10)
                YZ(i) = y(i)
            Next
    xx:
    
            'Colors
             red = RGB(255, 0, 0)
             yellow = RGB(255, 255, 0)
             blue = RGB(0, 0, 255)
             green = RGB(0, 255, 0)
            black = RGB(0, 0, 0)
            white = RGB(255, 255, 255)
              grey = RGB(125, 125, 125)
    
             If (LCase(backClr) = "red") Then bkcolor = red
             If (LCase(backClr) = "yellow") Then bkcolor = yellow
             If (LCase(backClr) = "blue") Then bkcolor = blue
            If (LCase(backClr) = "green") Then bkcolor = green
              If (LCase(backClr) = "black") Then bkcolor = black
             If (LCase(backClr) = "white") Then bkcolor = white
             If (LCase(backClr) = "grey") Then bkcolor = grey
    
            'clear graph
            Form3.Picture1.cls()
    
            Form3.Picture1.Width = 1
    
            'Draw x & y axes for graph
            WdP = VB6.PixelsToTwipsX(Form3.Picture1.Width)
            HtP = VB6.PixelsToTwipsY(Form3.Picture1.Height)
            SideLRP1 = 0.1 * WdP
            SideTBP1 = 0.1 * HtP
            ytwmax = SideTBP1
            ytwmin = HtP - 2.3 * SideTBP1
            xtwmin = 1.2 * SideLRP1
            xtwmax = WdP - SideLRP1
            'X0 = xtwmin
            'y0 = ytwmin
             Form3.Picture1.BackColor = System.Drawing.ColorTranslator.FromOle(bkcolor)
    
            Form3.Picture1.Line (xtwmin, ytwmin) - (xtwmax, ytwmin), white
    
            Form3.Picture1.Line (xtwmin, ytwmin) - (xtwmin, ytwmax), white
    
            'X-axis division and label
            '-------------------------
            Call MaxMin(n, XZ, xpmin, xpmax, IdMinx, IdMaxX)
            nplot = n
            'Use y = mx + c to calculate x-axis twip position
            mx = (xtwmax - xtwmin) / (xpmax - xpmin)
            cx = xtwmax - mx * xpmax
            VcplotEqn.mx = mx
            VcplotEqn.cx = cx
            'X label divide
            xint = (xpmax - xpmin) / NoIntervx
            xlabelx = xpmin
            Do While (1)
                Form3.Picture1.Line(pen, X, y, 10, 5) ' = ytwmin + 60
                xp1 = xlabelx * mx + cx
                Form3.Picture1.CurrentX = xp1 - 100
                yp1 = ytwmin
                Form3.Picture1.Font = VB6.FontChangeSize(Form3.Picture1.Font, FtSz)
                Form3.Picture1.Font = VB6.FontChangeBold(Form3.Picture1.Font, True)
               Form3.Picture1.ForeColor = System.Drawing.ColorTranslator.FromOle(green)
                 Form3.Picture1.Print(VB6.Format(10 ^ xlabelx, xformat))
                Form3.Picture1.Print Format(xlabelx, xformat)
              Form3.Picture1.Line (xp1, yp1) - (xp1, yp1 + 70), red
                 Form3.Picture1.DrawStyle = vbDot
              Form3.Picture1.Line (xp1, ytwmin) - (xp1, ytwmax), grey
                Form3.Picture1.DrawStyle = vbSolid
                If (xlabelx >= xpmax) Then Exit Do
                xlabelx = xlabelx + xint
            Loop
    
            'y-division and label
            Call MaxMin(n, YZ, ypmin, ypmax, idminy, Idmaxy)
            'provide margin at max and min y values
            ypmax = ypmax + System.Math.Abs(0.5 * ypmax)
            ypmin = ypmin - System.Math.Abs(0.5 * ypmin)
            ypmax = System.Math.Round(ypmax)
            ypmin = System.Math.Round(Int(ypmin))
    
            nplot = n
            'Use y = mx + c to calculate y-axis twip position
            my_Renamed = (ytwmax - ytwmin) / (ypmax - ypmin)
            cy = ytwmax - my_Renamed * ypmax
            VcplotEqn.my_Renamed = my_Renamed
            VcplotEqn.cy = cy
    
            'Ylabel divide
            Yint = (ypmax - ypmin) / NoIntervy
            ylabely = ypmin
            Do While (1)
                yp1 = my_Renamed * ylabely + cy
                xp1 = xtwmin
                yp2 = yp1 - 100
                xp2 = xp1 - 250
    
                Form3.Picture1.Font = VB6.FontChangeSize(Form3.Picture1.Font, FtSz)
                Form3.Picture1.CurrentX = xp2 - 200
                Form3.Picture1.CurrentY = yp2
                Form3.Picture1.Print(VB6.Format(ylabely, yformat))
               Form3.Picture1.Print (xp1, yp1) - (xp1 - 70, yp1), red
                 Form3.Picture1.DrawStyle = vbDot
                Form3.Picture1.Line (xp1, yp1) - (xtwmax, yp1), grey
                Form3.Picture1.DrawStyle = vbSolid
                If (ylabely >= ypmax) Then Exit Do
                ylabely = ylabely + Yint
            Loop
    
            'redraw axes and box
           		Form3.Picture1.Line (xtwmin, ytwmin) - (xtwmax, ytwmin), white
         		Form3.Picture1.Line (xtwmin, ytwmin) - (xtwmin, ytwmax), white
          		Form3.Picture1.Line (xtwmax, ytwmin) - (xtwmin, ytwmax), white, B
    
            Form3.Picture1.Width = 2
            'plot the curve
            For k = 1 To nplot - 1
                yp1 = my_Renamed * YZ(k) + cy
                yp2 = my_Renamed * YZ(k + 1) + cy
                xp1 = mx * XZ(k) + cx
                xp2 = mx * XZ(k + 1) + cx
    			Form3.Picture1.Line (xp1, yp1) - (xp2, yp2), yellow
            Next
        End Sub
    Problems with

    Form3.Picture1.Line
    Form3.Picture1.CurrentX = xp2 - 200
    Form3.Picture1.Print
    Form3.Picture1.cls()
    Form3.Picture1.CurrentY

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: Errors

    I'd advice you to rewrite your code from scratch rather than converting it like this.

    You've told us where the problem is, now could you tell us what the problem is? (The error messages)
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Errors

    Maybe you could also explain what you're actually trying to achieve, so we can advise you how best to achieve it in VB.NET. When moving from VB6 to VB.NET it's better to think in terms of functionality rather than code. If you try to convert code directly you will almost always end up with a suboptimal implementation.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    New Member yati's Avatar
    Join Date
    Jan 2009
    Location
    Malaysia
    Posts
    5

    Re: Errors

    actually my task is to move to VB net from VB6
    but i was given with short time,
    and i am just beginner in VB,
    so i just think to fix the errors and run it

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width