重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
效果如图,代码如下:
创新互联是一家专注于网站设计制作、网站建设与策划设计,张家港网站建设哪家好?创新互联做网站,专注于网站建设10余年,网设计领域的专业建站公司;建站业务涵盖:张家港等地区。张家港做网站价格咨询:028-86922220
Public Class Form1
'Circle类
Class Circle
Public Center As Point
Public Radius As Single
Public Sub New(c As Point, r As Single)
Center = c
Radius = r
End Sub
'绘制
Public Sub Draw(g As Graphics, pen As Pen)
g.DrawEllipse(pen, New RectangleF(Center.X - Radius, Center.Y - Radius, Radius * 2, Radius * 2))
End Sub
End Class
Private downPoint As Point '记录鼠标按下位置
Private circleList As New List(Of Circle) '已存放圆的列表
Private tmpCircle As Circle '临时圆(正在拖动)
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
DoubleBuffered = True '启用双缓冲绘图,避免闪烁
End Sub
Private Sub Form1_MouseDown(sender As Object, e As MouseEventArgs) Handles Me.MouseDown
downPoint = e.Location '记下位置
End Sub
Private Sub Form1_MouseMove(sender As Object, e As MouseEventArgs) Handles Me.MouseMove
If e.Button Windows.Forms.MouseButtons.Left Then Return '左键没按下则退出
Dim r As Single = Math.Sqrt((e.X - downPoint.X) ^ 2 + (e.Y - downPoint.Y) ^ 2) '算出半径
tmpCircle = New Circle(downPoint, r) '更新临时圆
Refresh() '先刷新掉之前绘制的临时圆
tmpCircle.Draw(Me.CreateGraphics, Pens.Black) '绘制临时圆
End Sub
Private Sub Form1_MouseUp(sender As Object, e As MouseEventArgs) Handles Me.MouseUp
circleList.Add(tmpCircle) '鼠标弹起,把临时圆加入圆列表
End Sub
Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
For Each c As Circle In circleList
c.Draw(e.Graphics, Pens.Black) '绘制出每个圆
Next
End Sub
End Class
VB的运算顺序是:先乘除、后加减,有括号的先算括号内,有负号的先算负号。
请你比较一下这个运算中x和y的值:
Dim n As Single = 4
Dim x As Single
Dim y As Single
x = n + 1
x = x / n
x = x - 1
x = Math.Sqrt(x)
y = Math.Sqrt((n + 1) / n - 1)
这样就会发现,你的代码中括号的位置错了。
正确的应该是: Math.Sqrt((n + 1) / n - 1)
不知道你代码哪里来的,但是我可以确定运行起来有不少问题
还有很多条件语言浪费,和格式转换问题,当然我也不清楚vb6中
这些问题是不是会被忽略,反正放到vb点虐 中是百分之百不能得出你要的结果的
还有就是你的代码不全,有些东西没法解释
'控件上鼠标移动事件处理进程
Private Sub PicCross_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
'变量声明
Dim alpha, xx, yy, radius As Single
'当出现错误是跳至下一行(即忽略错误)
On Error Resume Next
'xx赋值为鼠标X坐标-500,yy赋值鼠标Y坐标-500
'radius赋值r=根号下xx方加yy方(半径公式)
xx = X - 500
yy = Y - 500
radius = Sqr(xx * xx + yy * yy)
'当xx大于0时
If xx 0 Then
'当yy大于0时
If yy 0 Then
'alpha赋值为yy/xx*57.29578所得结果的反正切值
alpha = Atn(yy / xx) * 57.29578
'当yy小等于0时
Else
'alpha赋值为yy/xx*57.29578+360所得结果的反正切值
alpha = Atn(yy / xx) * 57.29578 + 360
End If
End If
'当xx小于0时
If xx 0 Then
'alpha赋值为yy/xx*57.29578+180所得结果的反正切值
alpha = Atn(yy / xx) * 57.29578 + 180
End If
'当radius大等于350时
If radius = 350 Then
'PicCross控件集的第Index控件的ToolTipText(小提示属性)等于 轴向:Text8控件集第Index控件中所含内容数字形式乘以length值除以50(转格式00.0) 径向:alpha(转格式00.0) 温度:Text8控件集第Index控件中所含内容乘以50除以length的整数内容调用disData并去除首尾不必要空格
PicCross(Index).ToolTipText = "轴向:" + Format(Val(Text8(Index).Text) * length / 50, "00.0") + " 径向:" + Format(alpha, "00.0") + " 温度:" + Trim(disData(Index, Int(Text8(Index).Text * 50 / length), Int(alpha / 9)))
'当radius小于350时
Else
'PicCross控件集的第Index控件的ToolTipText(小提示属性)等于 空
PicCross(Index).ToolTipText = ""
End If
End Sub
'控件PicShow双击事件
Private Sub PicShow_DblClick(Index As Integer)
'当出现错误是跳至下一行(即忽略错误)
On Error Resume Next
绝对值是“|”,可以直接显示,同理对数可用log(x)代替,根号和其他不支持显示。
如果要显示数学式子,只能画吧。
计算时可用“^”求幂或求根,“/”表示除法和分数线,还有math类。