Tác giả: truongphu
Mô tả: Scale một picture, vẽ đồ thị biểu diễn
Lâu ngày đụng vẽ, mất hơn tiếng đồng hồ. Nhân câu hỏi bạn anhtuan1285
Using vb Syntax Highlighting
Dim i As Long, CôngSuât(1 To 24) As Integer
' tang ban anhtuan1285 20/5/2010
Private Sub ToaDo() ' Code truongphu
'Picture1.Cls
Picture1.Scale (-1, 100)-(25, -2) ' x tu' -1 Ðê'n 25 y tu' 100 xuô'ng -2
Picture1.Line (0, 0)-(25, 0), vbBlack ' Draw X axis: x=0->25 y=0
For i = 0 To 25
Picture1.Line (i, -2)-(i, 0), vbBlack ' Ðánh dâ'u
' môi i là môt nâ'c 1, chiê`u cao theo ti lê y tu'` -2-> 0
Next i
Picture1.Line (0, 100)-(0, 0), vbBlack ' Draw Y axis: x=0 y=100-> 0
For i = 0 To 100 Step 5 ' y Ðon vi lo'n nên step 5
Picture1.Line (-0.5, i)-(0, i), vbBlack
'môi i là nâ'c 5, chiê`u dái theo ti lê x tu' -0.5 -> 0
Next i
End Sub
Private Sub Command1_Click()
ToaDo
End Sub
Private Sub Command2_Click()
Dim TÐ As Integer
For i = 0 To 24
TÐ = Int(Rnd * 30) + 70
If i > 0 Then
Picture1.Line (i, 0)-(i, TÐ), vbRed
CôngSuât(i) = TÐ
End If
Next
End Sub
Private Sub Command3_Click()
For i = 2 To 24
Picture1.Line (i - 1, CôngSuât(i - 1))-(i, CôngSuât(i)), vbBlue
Next
End Sub
Private Sub Form_Paint()
' In trên form Toa Ðô truc Y
Me.CurrentX = 0
Me.CurrentY = Picture1.Top - 100
Me.Print "100 MW"
Me.CurrentY = Picture1.Top + 2700
Me.Print " 0 MW"
Me.CurrentY = Picture1.Top + 1350
Me.Print " 50 MW"
' In trên Form Toa Ðô truc X
Me.CurrentX = Picture1.Left - 50
Me.CurrentY = Picture1.Top + 100 + Picture1.Height
Me.Print "Gio'`:"
Me.CurrentY = Picture1.Top + 100 + Picture1.Height
Me.CurrentX = Picture1.Left + 400
Me.Print 1
Me.CurrentY = Picture1.Top + 100 + Picture1.Height
Me.CurrentX = Picture1.Left + Picture1.Width - 350
Me.Print 24
Me.CurrentY = Picture1.Top + 100 + Picture1.Height
Me.CurrentX = Picture1.Left + 2800
Me.Print 12
End Sub
' tang ban anhtuan1285 20/5/2010
Private Sub ToaDo() ' Code truongphu
'Picture1.Cls
Picture1.Scale (-1, 100)-(25, -2) ' x tu' -1 Ðê'n 25 y tu' 100 xuô'ng -2
Picture1.Line (0, 0)-(25, 0), vbBlack ' Draw X axis: x=0->25 y=0
For i = 0 To 25
Picture1.Line (i, -2)-(i, 0), vbBlack ' Ðánh dâ'u
' môi i là môt nâ'c 1, chiê`u cao theo ti lê y tu'` -2-> 0
Next i
Picture1.Line (0, 100)-(0, 0), vbBlack ' Draw Y axis: x=0 y=100-> 0
For i = 0 To 100 Step 5 ' y Ðon vi lo'n nên step 5
Picture1.Line (-0.5, i)-(0, i), vbBlack
'môi i là nâ'c 5, chiê`u dái theo ti lê x tu' -0.5 -> 0
Next i
End Sub
Private Sub Command1_Click()
ToaDo
End Sub
Private Sub Command2_Click()
Dim TÐ As Integer
For i = 0 To 24
TÐ = Int(Rnd * 30) + 70
If i > 0 Then
Picture1.Line (i, 0)-(i, TÐ), vbRed
CôngSuât(i) = TÐ
End If
Next
End Sub
Private Sub Command3_Click()
For i = 2 To 24
Picture1.Line (i - 1, CôngSuât(i - 1))-(i, CôngSuât(i)), vbBlue
Next
End Sub
Private Sub Form_Paint()
' In trên form Toa Ðô truc Y
Me.CurrentX = 0
Me.CurrentY = Picture1.Top - 100
Me.Print "100 MW"
Me.CurrentY = Picture1.Top + 2700
Me.Print " 0 MW"
Me.CurrentY = Picture1.Top + 1350
Me.Print " 50 MW"
' In trên Form Toa Ðô truc X
Me.CurrentX = Picture1.Left - 50
Me.CurrentY = Picture1.Top + 100 + Picture1.Height
Me.Print "Gio'`:"
Me.CurrentY = Picture1.Top + 100 + Picture1.Height
Me.CurrentX = Picture1.Left + 400
Me.Print 1
Me.CurrentY = Picture1.Top + 100 + Picture1.Height
Me.CurrentX = Picture1.Left + Picture1.Width - 350
Me.Print 24
Me.CurrentY = Picture1.Top + 100 + Picture1.Height
Me.CurrentX = Picture1.Left + 2800
Me.Print 12
End Sub
Parsed in 0.013 seconds, using GeSHi 1.0.8.4
Hình chụp:


