在excel 的sheet中画坐标轴及函数图像

一、参数的窗体配置

 

二、窗体中三个按钮的代码:

Private Sub CommandButton1_Click()
    Dim X0 As Single, Y0 As Single, X1 As Single, Y1 As Single, X2 As Single, Y2 As Single
    Dim nX1 As Integer, nX As Integer, nY1 As Integer, nY As Integer, nL As Integer, nB As Integer, i As Integer, T1 As Integer
    Dim XLine As Shape, YLine As Shape, MyTextbox As Shape
    Dim ct As Single, M As Byte, MyValue As Single, ModValue As Byte
  
    On Error Resume Next ''忽略错误
    ''必要数据判断
    If Me.TextBox1 = "" Or Int(Me.TextBox1) <> Me.TextBox1 * 1 Or Me.TextBox1 * 1 <= 0 Then MsgBox "请输入正整数! ", vbInformation: Exit Sub
    If Me.TextBox2 = "" Or Int(Me.TextBox2) <> Me.TextBox2 * 1 Or Me.TextBox2 * 1 <= 0 Then MsgBox "请输入正整数! ", vbInformation: Exit Sub
    If Me.TextBox3 = "" Or Int(Me.TextBox3) <> Me.TextBox3 * 1 Or Me.TextBox3 * 1 < 0 Then MsgBox "请输入自然数! ", vbInformation: Exit Sub
    If Me.TextBox4 = "" Or Int(Me.TextBox4) <> Me.TextBox4 * 1 Or Me.TextBox4 * 1 <= 0 Then MsgBox "请输入正整数! ", vbInformation: Exit Sub
    If Me.TextBox5 = "" Or Int(Me.TextBox5) <> Me.TextBox5 * 1 Or Me.TextBox5 * 1 < 0 Then MsgBox "请输入自然数! ", vbInformation: Exit Sub
    If Me.TextBox6 = "" Or Int(Me.TextBox6) <> Me.TextBox6 * 1 Or Me.TextBox6 * 1 <= 0 Then MsgBox "请输入正整数! ", vbInformation: Exit Sub
    If Me.TextBox3 * 1 > Me.TextBox1 * 1 Or Me.TextBox6 * 1 > Me.TextBox2 * 1 Then MsgBox "无效数据!", vbInformation: Exit Sub
 
    Application.ScreenUpdating = False
    ''计算坐标轴交点及端点坐标,厘米转换为磅数,两端加长画箭头
    X0 = Application.CentimetersToPoints(Me.TextBox1)   '横轴原点的位置

    Y0 = Application.CentimetersToPoints(Me.TextBox2)'纵轴原点的位置
    T1 = Me.TextBox3 * 1

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值