Question scaleHeight ScaleWidth Vb6 to VB net

vuduckien2011

New member
Joined
Sep 7, 2016
Messages
3
Programming Experience
Beginner
Hi everybody. I need help on properties and scaleHeight ScaleWidth when converting code from vb6 to VB.net . Hope everybody help please?
 
We might be able to help if we have a less vague description of the problem. Please provide a FULL and CLEAR explanation of EXACTLY what you're trying to achieve.

Also, keep in mind that trying to translate VB6 code to VB.NET line by line is often a good way to end up with bad VB.NET code. You're generally better off considering the functionality that the VB6 code provides and then trying to determine the best way to provide that same functionality in VB.NET.
 
How to return or set the number of units for the horizontal and vertical measurement of the interior of an object when using graphics methods or when positioning controls. I used graphics.drawline in vb.net
 
in vb6 :
VB.NET:
  Public Sub Plot_dothi(ByRef N As Integer)
     Pct1.ScaleWidth = Pct1W
        For i = 1 To Pct1W - 1
                Pct1.Line (i, Pct1.ScaleHeight - mang(i + STTKenhcu))-(i, Pct1.ScaleHeight), &HFFFF00, B
       Next i
                Pct1.Line (N, Pct1.ScaleHeight)-(N, 0), RGB(255, 255, 255)
End sub
Private Sub Pct1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    STTKenhmoi = STTKenhcu + Round(x)
    vitridanhdau = Round(x)
    Display (STTKenhmoi)
End Sub


Private Sub Pct1_Click()
Plot_dothi (vitridanhdau)
End Sub



in VB.net :
 Private thmb = New Bitmap(CInt(4096), CInt(650))
  private Graphics As Graphics = Graphics.FromImage(thmb)


 Private Sub drawLine(Gr As Graphics, Pn As Pen, X1 As Integer, Y1 As Integer, X2 As Integer, Y2 As Integer)
        Dim ScaledX1 As Integer = CInt(Math.Round((CSng(X1) / Pct1W) * Pct1.ClientSize.Width))
        Dim ScaledX2 As Integer = CInt(Math.Round((CSng(X2) / Pct1W) * Pct1.ClientSize.Width))
        Dim ScaledY1 As Integer = CInt(Math.Round((CSng(Y1) / mScaleHeight) * Pct1.ClientSize.Height))
        Dim ScaledY2 As Integer = CInt(Math.Round((CSng(Y2) / mScaleHeight) * Pct1.ClientSize.Height))
        Gr.DrawLine(Pn, ScaledX1, ScaledY1, ScaledX2, ScaledY2)
    End Sub


  Public Sub Plot_dothi(ByRef N As Integer)
          For i = 1 To Pct1W - 1
            drawLine(Graphics, Pens.Cyan, i, mScaleHeight - mang(i + STTKenhcu), i, mScaleHeight)
        Next i
           Pct1.Image = thmb
           drawLine(Graphics, Pens.WhiteSmoke, N, mScaleHeight, N, 0)
End sub


 Private Sub Pct1_MouseDown(sender As Object, e As MouseEventArgs) Handles Pct1.MouseDown
        STTKenhmoi = STTKenhcu + Math.Round(e.X)
        vitridanhdau = Math.Round(e.X)
        Display(STTKenhmoi)
    End Sub


 Private Sub Pct1_Click(sender As Object, e As EventArgs) Handles Pct1.Click
        Plot_dothi(vitridanhdau)
    End Sub

in vb6 : when I change the value Pct1W ( Pct1Scale.width = Pct1W ) , the cursor position on the picturebox drawn with lines of code ( DrawLine (Graphics , Pens.WhiteSmoke , N , mScaleHeight , N , 0 ) ) unchanged . How to do in VB.net ?
 
Back
Top