给段我的代码Dim x As Double Dim y As Double Dim x1 As Double Dim y1 As Double Dim x2 As Double Dim y2 As Double Dim i As Long Dim MaxJ As Double Dim MinJ As Double Dim j(40, 2) As Double Dim t As Integer Dim bl As Double MaxJ = 0 MinJ = 10000000 Dim r As New ADODB.Recordset Dim SQL As String cn.Open "Driver={SQL Server};Server=192.168.100.100;Uid=sa;Pwd=**********;Database=sbcweb"Picture1.Cls Text1 = "" SQL = "select top 40 * from waihui where hb='" & List1 & "' order by rq desc" r.Open SQL, cn If Not (r.EOF And r.BOF) Then Picture1.DrawWidth = 1
'中间的水平线 Picture1.Line (0, Picture1.Height / 2)-(Picture1.Width, Picture1.Height / 2), QBColor(12) '画40根素县 For i = 1 To 40 Picture1.Line (i * Picture1.Width / 41, 0)-(i * Picture1.Width / 41, Picture1.Height), QBColor(8) Next i = 0 '读出到数珠 Do While Not r.EOF i = i + 1 j(i, 1) = r!mcj j(i, 2) = r!xhmr If MaxJ < r!mcj Then MaxJ = r!mcj If MinJ > r!xhmr Then MinJ = r!xhmr Text1 = r!mcj & vbCrLf & Text1 r.MoveNext Loop t = i 'bl = Picture1.Height / (MaxJ - MinJ)Picture1.DrawWidth = 3 '画第一根线 For i = t To 1 Step -1 x = (t - i) * Picture1.Width / 41 y = 0.8 * Picture1.Height * (MaxJ - j(i, 1)) / (MaxJ - MinJ) + 0.1 * Picture1.Height If y1 = 0 Then y1 = y y2 = y x2 = x Picture1.Line (x1, y1)-(x2, y2), QBColor(12) y1 = y2 x1 = x2 Next x1 = 0 y1 = 0 '画第二根线For i = t To 1 Step -1 x = (t - i) * Picture1.Width / 41 y = 0.8 * Picture1.Height * (MaxJ - j(i, 2)) / (MaxJ - MinJ) + 0.1 * Picture1.Height If y1 = 0 Then y1 = y y2 = y x2 = x Picture1.Line (x1, y1)-(x2, y2), QBColor(10) Debug.Print i - t, , x1, y1, x2, y2 y1 = y2 x1 = x2 Next'For i = t To 1 Step -1 ' x = (t - i) * Picture1.Width / 41 ' y1 = 0.8 * Picture1.Height * (MaxJ - j(i, 1)) / (MaxJ - MinJ) + 0.1 * Picture1.Height ' y2 = 0.8 * Picture1.Height * (MaxJ - j(i, 2)) / (MaxJ - MinJ) + 0.1 * Picture1.HeightPicture1.Line (0, 0)-(1, 1), QBColor(1) Picture1.ForeColor = QBColor(15) Picture1.Print List1 & " 在40天内最高价:" & MaxJ & "最低价:" & MinJ End Ifr.Close cn.Close
Private Sub Picture2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim lenght As Integer Dim high As Integer high = Picture2.Height lenght = Picture2.Width Picture2.Line (0, 0)-(lenght - 10, 0), &H80000009 Picture2.Line -(lenght - 10, high), &H80000009 End Sub这是我写的,如果将两个(lenght-10)写成(lenght-1)画的右边的线就画到picturebox外面了。Drawwidth我是1,scalemode是TWIP
Dim y As Double
Dim x1 As Double
Dim y1 As Double
Dim x2 As Double
Dim y2 As Double
Dim i As Long
Dim MaxJ As Double
Dim MinJ As Double
Dim j(40, 2) As Double
Dim t As Integer
Dim bl As Double
MaxJ = 0
MinJ = 10000000
Dim r As New ADODB.Recordset
Dim SQL As String
cn.Open "Driver={SQL Server};Server=192.168.100.100;Uid=sa;Pwd=**********;Database=sbcweb"Picture1.Cls
Text1 = ""
SQL = "select top 40 * from waihui where hb='" & List1 & "' order by rq desc"
r.Open SQL, cn
If Not (r.EOF And r.BOF) Then
Picture1.DrawWidth = 1
'中间的水平线
Picture1.Line (0, Picture1.Height / 2)-(Picture1.Width, Picture1.Height / 2), QBColor(12)
'画40根素县
For i = 1 To 40
Picture1.Line (i * Picture1.Width / 41, 0)-(i * Picture1.Width / 41, Picture1.Height), QBColor(8)
Next
i = 0
'读出到数珠
Do While Not r.EOF
i = i + 1
j(i, 1) = r!mcj
j(i, 2) = r!xhmr
If MaxJ < r!mcj Then MaxJ = r!mcj
If MinJ > r!xhmr Then MinJ = r!xhmr
Text1 = r!mcj & vbCrLf & Text1
r.MoveNext
Loop
t = i
'bl = Picture1.Height / (MaxJ - MinJ)Picture1.DrawWidth = 3
'画第一根线
For i = t To 1 Step -1
x = (t - i) * Picture1.Width / 41
y = 0.8 * Picture1.Height * (MaxJ - j(i, 1)) / (MaxJ - MinJ) + 0.1 * Picture1.Height
If y1 = 0 Then y1 = y
y2 = y
x2 = x
Picture1.Line (x1, y1)-(x2, y2), QBColor(12)
y1 = y2
x1 = x2
Next
x1 = 0
y1 = 0
'画第二根线For i = t To 1 Step -1
x = (t - i) * Picture1.Width / 41
y = 0.8 * Picture1.Height * (MaxJ - j(i, 2)) / (MaxJ - MinJ) + 0.1 * Picture1.Height
If y1 = 0 Then y1 = y
y2 = y
x2 = x
Picture1.Line (x1, y1)-(x2, y2), QBColor(10)
Debug.Print i - t, , x1, y1, x2, y2 y1 = y2
x1 = x2
Next'For i = t To 1 Step -1
' x = (t - i) * Picture1.Width / 41
' y1 = 0.8 * Picture1.Height * (MaxJ - j(i, 1)) / (MaxJ - MinJ) + 0.1 * Picture1.Height
' y2 = 0.8 * Picture1.Height * (MaxJ - j(i, 2)) / (MaxJ - MinJ) + 0.1 * Picture1.HeightPicture1.Line (0, 0)-(1, 1), QBColor(1)
Picture1.ForeColor = QBColor(15)
Picture1.Print List1 & " 在40天内最高价:" & MaxJ & "最低价:" & MinJ
End Ifr.Close
cn.Close
Dim lenght As Integer
Dim high As Integer
high = Picture2.Height
lenght = Picture2.Width
Picture2.Line (0, 0)-(lenght - 10, 0), &H80000009
Picture2.Line -(lenght - 10, high), &H80000009
End Sub这是我写的,如果将两个(lenght-10)写成(lenght-1)画的右边的线就画到picturebox外面了。Drawwidth我是1,scalemode是TWIP