一共有两个问题
一
CommonDialog1.CancelError = True
OnErrorGoToErr
CommonDialog1.Filter = "text files(*.text)| *.txt|" & "all files(*.*) | *.*"
CommonDialog1.Flags = &H4
CommonDialog1.ShowOpen
Text1.Text = CommonDialog1.FileName
fname = CommonDialog1.FileName
Exit Sub
Err:
Exit Sub
这段程序中的OnErrorGoToErr语句应该怎么用,我这种写法运行时会显示"子函数和函数未定议",我应该怎么用?
二
我想在一个picturebox图片框中利用算出的数据画出曲线图,VB默认的坐标单位时缇,而我的数据单位是厘米.书上写567缇等于一厘米,我是不是用数据直接乘567就行了?我的程序如下:
Private Sub DrawAxis(MyPicture As PictureBox)
Dim x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer
Dim y As Integer, count As Integer, sum As Integer
Dim ave As Single, tp As Single, x3 As Single, y3 As Single, x4 As Single, y4 As Single
ave = 0: tp = 0
MyPicture.BackColor = QBColor(0) '画出X,Y坐标轴
MyPicture.Cls
MyPicture.DrawStyle = 0
x1 = 200
y1 = (MyPicture.ScaleHeight - 200)
y = y1 / 2
x2 = (MyPicture.ScaleWidth - 200)
y2 = 200
keyp(1) = x2
MyPicture.Line (x1, y1)-(x1, y2), QBColor(11)
MyPicture.Line (x1, y)-(x2, y), QBColor(11)
MyPicture.Line (x1 - 50, y2 + 120)-(x1, y2), QBColor(11)
MyPicture.Line (x1 + 50, y2 + 120)-(x1, y2), QBColor(11)
MyPicture.Line (x2 - 120, y + 50)-(x2, y), QBColor(11)
MyPicture.Line (x2 - 120, y - 50)-(x2, y), QBColor(11) ave = (MyPicture.ScaleWidth - 400) / N '将X轴N等分
MyPicture.PSet (x1, y), QBColor(12) '在X轴上画出N个等分点
For count = 2 To N
sum = count - 1
keyp(count) = keyp(sum) + ave
tp = tp + ave
MyPicture.PSet (x1 + tp, y), QBColor(12)
Next count
For count = 1 To N '计算出Y轴方向的坐标
temp(count) = Arafa(count) * 567 'arafa数组数据已经求出
Next count
For count = 1 To N - 1 '用X,Y的坐标值画出曲线
sum = count + 1
x3 = keyp(count): y3 = temp(count)
x4 = keyp(sum): y4 = temp(sum)
MyPicture.Line (x3, y3)-(x4, y4), QBColor(11)
MyPicture.PSet (x3, y3), QBColor(15)
Next count
上述程序到画曲线之前都好使,但就是画不出曲线,不知道错在哪里?请各位指教
End SubPrivate Sub mainCommanddraw_Click()
showForm.Show
showForm.PicDraw.AutoRedraw = True
Call DrawAxis(showForm.PicDraw)
End Sub
一
CommonDialog1.CancelError = True
OnErrorGoToErr
CommonDialog1.Filter = "text files(*.text)| *.txt|" & "all files(*.*) | *.*"
CommonDialog1.Flags = &H4
CommonDialog1.ShowOpen
Text1.Text = CommonDialog1.FileName
fname = CommonDialog1.FileName
Exit Sub
Err:
Exit Sub
这段程序中的OnErrorGoToErr语句应该怎么用,我这种写法运行时会显示"子函数和函数未定议",我应该怎么用?
二
我想在一个picturebox图片框中利用算出的数据画出曲线图,VB默认的坐标单位时缇,而我的数据单位是厘米.书上写567缇等于一厘米,我是不是用数据直接乘567就行了?我的程序如下:
Private Sub DrawAxis(MyPicture As PictureBox)
Dim x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer
Dim y As Integer, count As Integer, sum As Integer
Dim ave As Single, tp As Single, x3 As Single, y3 As Single, x4 As Single, y4 As Single
ave = 0: tp = 0
MyPicture.BackColor = QBColor(0) '画出X,Y坐标轴
MyPicture.Cls
MyPicture.DrawStyle = 0
x1 = 200
y1 = (MyPicture.ScaleHeight - 200)
y = y1 / 2
x2 = (MyPicture.ScaleWidth - 200)
y2 = 200
keyp(1) = x2
MyPicture.Line (x1, y1)-(x1, y2), QBColor(11)
MyPicture.Line (x1, y)-(x2, y), QBColor(11)
MyPicture.Line (x1 - 50, y2 + 120)-(x1, y2), QBColor(11)
MyPicture.Line (x1 + 50, y2 + 120)-(x1, y2), QBColor(11)
MyPicture.Line (x2 - 120, y + 50)-(x2, y), QBColor(11)
MyPicture.Line (x2 - 120, y - 50)-(x2, y), QBColor(11) ave = (MyPicture.ScaleWidth - 400) / N '将X轴N等分
MyPicture.PSet (x1, y), QBColor(12) '在X轴上画出N个等分点
For count = 2 To N
sum = count - 1
keyp(count) = keyp(sum) + ave
tp = tp + ave
MyPicture.PSet (x1 + tp, y), QBColor(12)
Next count
For count = 1 To N '计算出Y轴方向的坐标
temp(count) = Arafa(count) * 567 'arafa数组数据已经求出
Next count
For count = 1 To N - 1 '用X,Y的坐标值画出曲线
sum = count + 1
x3 = keyp(count): y3 = temp(count)
x4 = keyp(sum): y4 = temp(sum)
MyPicture.Line (x3, y3)-(x4, y4), QBColor(11)
MyPicture.PSet (x3, y3), QBColor(15)
Next count
上述程序到画曲线之前都好使,但就是画不出曲线,不知道错在哪里?请各位指教
End SubPrivate Sub mainCommanddraw_Click()
showForm.Show
showForm.PicDraw.AutoRedraw = True
Call DrawAxis(showForm.PicDraw)
End Sub
On Error GoTo Err
图片框坐标单位是厘米