06-11-2007, 13:41
|
|
|
חבר מתאריך: 16.09.05
הודעות: 196
|
|
יצירת גרף בVB על בסיס מערכים - עזרה
Private Sub cmdDraweF2_Click()
Dim xw1 As Integer, xw2 As Integer, xw As Integer
Dim yw1 As Integer, yw2 As Integer, yw As Integer
Dim X1 As Single, X2 As Single
Dim Y1 As Single, Y2 As Single, Ywmid As Integer, Ymax
Dim Kx As Single, Ky As Single
xw1 = 1000 ' Koord of window
xw2 = 5000
yw1 = 1000
yw2 = 5000
Ywmid = (yw1 + yw2) / 2
Line (xw1, Ywmid)-(xw2, Ywmid) ' Zir X
dwx = xw2 - xw1
dwy = (yw2 - yw1) / 2 ' !!!!! hiluk by 2
X1 = 0 'from table of Function
X2 = 300
Y2 = 180
Kx = (xw2 - xw1) / (X2 - X1) '(xw2 - xw1)
'Ky = (yw2 - yw1) / (Y2 - Y1) '(yw2 - yw1)
Ky = dwy / 60 ' Ymax
CurrentX = xw1 ' CurrentX,CurrentY - const of VB
CurrentY = Ywmid - Ky * F(X1)
DrawWidth = 2
For X = X1 To X2 Step 0.5
xw = xw1 + Kx * (X - X1)
yw = Ywmid - Ky * F(X)
Line -(xw, yw)
Next X
End Sub
Function F(ByVal X As Single)
Dim Y As Integer
Dim time(5), temp(5) As Integer
Dim i, time1, time2, temp1, temp2 As Integer
time(0) = 0
time(1) = 20
time(2) = 90
time(3) = 120
time(4) = 130
time(5) = 300
temp(0) = 20
temp(1) = 30
temp(2) = 55
temp(3) = 40
temp(4) = 30
temp(5) = 60
For i = 0 To 4
If (X > time(i)) And (X < time(i + 1)) Then
time1 = time(i)
time2 = time(i + 1)
temp1 = temp(i)
temp2 = temp(i + 1)
End If
Next i
Y = temp1 + (temp2 - temp1) / (time2 - time1) * X
End Function
התוכנית אמורה ליצור גרף על בסיס המערכים
time ו- temp
אולם התוכנית אינה עובדת לי...
מישהו בבקשה יכול לתקן את השגיאות בתוכנית שכתבתי?
תודה
|