Convert to VB.Net

  • Thread starter Thread starter yxq
  • Start date Start date
Y

yxq

Hello
Can anyone convert the vb6 code to vb.net? Thank you!

**************************************************************
Const SPACE = 5
Const BAR_WIDTH = 50
Public GraphPoints(0 To 99) As Long


Sub DrawUsage(lUsage As Long, picPercent As PictureBox, picGraph As
PictureBox)
Dim Cnt As Long
picPercent.ScaleMode = vbPixels
For Cnt = 0 To 10
picPercent.Line (SPACE, SPACE + Cnt * 3)-(SPACE + BAR_WIDTH, SPACE +
Cnt * 3 + 1), IIf(lUsage >= 100 - Cnt * 10 And lUsage <> 0, &HC000&,
&H4000&), BF
Next Cnt
ShiftPoints
GraphPoints(UBound(GraphPoints)) = lUsage
picGraph.Cls
For Cnt = LBound(GraphPoints) To UBound(GraphPoints) - 1
picGraph.Line (Cnt, 100 - GraphPoints(Cnt))-(Cnt + 1, 100 -
GraphPoints(Cnt + 1)), &H8000&
Next Cnt
End Sub


'Shift all the points from the graph one place to the left
Sub ShiftPoints()
Dim Cnt As Long
For Cnt = LBound(GraphPoints) To UBound(GraphPoints) - 1
GraphPoints(Cnt) = GraphPoints(Cnt + 1)
Next Cnt
End Sub
****************************************************************************
***********************
 
This might sound a little unhelpful but. If you cant even be bothered to
look up the correct syntax for the Const declarations at the beginning, I
dont feel like helping you.

Try doing a bit more for yourself and then come back with specifics !

Regards OHM
 
Hello
I have convertd some code, but it works not well.
*******************************************************
Const SPACE As Short = 5
Const BAR_WIDTH As Short = 50
Private GraphPoints(99) As Integer

Sub Draw1(ByVal lUsage As Integer, ByVal picPercent As PictureBox, ByVal
picGraph As PictureBox)
Dim Cnt As Integer
For Cnt = 0 To 10
Dim p1 As New
Pen(System.Drawing.ColorTranslator.FromOle(&HC000&), 2)
Dim p2 As New
Pen(System.Drawing.ColorTranslator.FromOle(&H4000&), 2)
Dim x1 As New Point(SPACE, SPACE + Cnt * 3)
Dim x2 As New Point(SPACE + BAR_WIDTH, SPACE + Cnt * 3 + 1)

Dim e As Graphics = picPercent.CreateGraphics
If lUsage >= 100 - Cnt * 10 And lUsage <> 0 Then
e.DrawLine(p1, x1, x2)
Else
e.DrawLine(p2, x1, x2)
End If
Next Cnt


'The code below can not work well..........

'Shift all the points from the graph one place to the left
For Cnt = LBound(GraphPoints) To UBound(GraphPoints) - 1
GraphPoints(Cnt) = GraphPoints(Cnt + 1)
Next Cnt

Dim e2 As Graphics = picGraph.CreateGraphics
GraphPoints(UBound(GraphPoints)) = lUsage
e2.Clear(Color.Black)
Dim p As New Pen(Color.Green, 1)
For Cnt = LBound(GraphPoints) To UBound(GraphPoints) - 1
Dim x3 As New Point(Cnt, 100 - GraphPoints(Cnt))
Dim x4 As New Point(Cnt + 1, 100 - GraphPoints(Cnt + 1))
e2.DrawLine(p, x3, x4)
Next Cnt
End Sub
*************************************************************
 
Not clear what you are trying to acheive with this code. What are you
expecting to happen when you call Draw1 ?

OHM
 
Hi YXQ

I thought OHM was very clear, if you would try to do yourself first the
mainpart he would help you with the difficult things,

But now you thinks you have in this newsgroup someone working for you for
free.

I think that wehne you show that you did make a start trying it, HM or
another will help you than with the real problems, but not more than 5 rows
in a time I think.

Cor.
 
Back
Top