关于vb.netx2的信息

VB.NET 一次函数求横坐标不是已经回答vb.netx2了吗vb.netx2?
运行界面如下图:
在对应的文本框里输入对应的坐标值vb.netx2,单击【计算】vb.netx2,结果将显示在下面一个文本框里 , 完整代码如下:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim x2, y2, x3, y3, x4, y4, x5, y5 As Single
Dim L As Single
x2 = Val(TextBox2.Text)
y2 = Val(TextBox3.Text)
x3 = Val(TextBox4.Text)
y3 = Val(TextBox5.Text)
x4 = Val(TextBox6.Text)
y4 = Val(TextBox7.Text)
'求点P3(x3,y3)与点P4(x4,y4)的直线方程;
'(X-x4)/(x3-x4) = (Y-y4)/(y3-y4) ......(1)
'求过点P2(x2,y2)的水平直线方程为;
'Y = y2 ......(2)
'方程(1)(2) 联立可以求出两条直线的交点(x5,y5)
'由此得到交点坐标为:
x5 = (y2 - y3) * (x4 - x3) / (y4 - y3)x3
y5 = y2
'求点P2(x2,y2)与点P5(x5,y5)之间的距离
'根据两点之间距离公式有;
L = ((x2 - x5) ^ 2(y2 - y5) ^ 2) ^ 0.5
TextBox1.Text = L
End Sub
End Class
vb.net 画线再画保留以前画得可以把所有画的线都保存在一个列表中,画的时候全部画出即可 。如下:
Public Class Form1
Class Line'直线类
Public Point1, Point2 As Point'成员 , 直线的两个端点
Sub New(p1 As Point, p2 As Point)'构造方法
Point1 = p1
Point2 = p2
End Sub
Public Sub Draw(g As Graphics)'绘制方法
g.DrawLine(Pens.Black, Point1, Point2)
End Sub
End Class
Private Lines As New List(Of Line)'列表用于保存所有画下的直线
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
BackColor = Color.White
DoubleBuffered = True'开启双缓冲可有效避免闪烁
End Sub
Private Sub Form1_MouseDown(sender As Object, e As MouseEventArgs) Handles Me.MouseDown
Lines.Add(New Line(e.Location, e.Location))'在直线列表中添加直线
End Sub
Private Sub Form1_MouseMove(sender As Object, e As MouseEventArgs) Handles Me.MouseMove
If e.ButtonWindows.Forms.MouseButtons.Left Then Return '左键未按下
'鼠标拖动时改变列表最后一条直线(也即当前直线的第二个端点)
Lines(Lines.Count - 1).Point2 = e.Location
Refresh()'刷新窗体
End Sub
'在Form的Paint事件中绘制所有直线 , 每次Form1重绘时都会触发Paint事件
'PS: 也可以通过重写OnPaint方法来达到类似的效果
Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias'开启抗锯齿
For Each l In Lines'遍历所有直线
l.Draw(e.Graphics)'调用绘制方法,传入的参数可以理解为画布
Next
End Sub
End Class
运行效果:
用VB.NET编写一个程序 :编一求阶乘的函数f(n),主调程序求组合数的程序,分别调用f(n),用来计算组合数的值Private Sub Command1_Click()
Dim A, B, C
A = 10
B = 3
C = f(A) / (f(B) * f(A - B))
Print C
End Sub
Private Function f(n)
Dim I As Integer
f = 1
For I = 1 To n
f = f * I
Next I
End Function
【关于vb.netx2的信息】关于vb.netx2和的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

    推荐阅读