将c语言程序转化为vb格式,请大神帮我把C语言转换成VB语言

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

‘VB6的写法

Option Explicit

Const PI = 3.1415926

Const Num = 36

Const Num1 = Num + 1

Private Sub Form_Activate()

Dim M%, i%, flag%

Dim L1!, L2!, L3!, L4!, w1!

Dim w2#, w3#

Dim e1#(Num1)

Dim e2#(Num1), u2#(Num1), d2#(Num1)

Dim e3#(Num1), u3#(Num1), d3#(Num1)

Dim s1#, s2#, s3#, A#, B#, C#, deta1#, D#, E#, F#, deta2#

Dim x1#, x2#, y1#, y2#

Dim inputstr As String, value() As String

Me.AutoRedraw = True

Me.ScaleMode = 3

inputstr = InputBox("Please input data: L1,L2,L3,L4,w1,M:")

value = Split(inputstr, ",")

L1 = CSng(value(0)): L2 = CSng(value(1)): L3 = CSng(value(2))

L4 = CSng(value(3)): w1 = CSng(value(4)): M = CSng(value(5))

Print "============================================================"

Print " i e1 e2 e3 w2 w3 d2 d3"

Print " (DEG) (DEG) (DEG) (rad/s) (rad/s) (rad/s2) (rad/s2)"

Print "------------------------------------------------------------"

For i = 0 To Num

e1(i) = 360# / Num * i

s1 = PI / 180# * e1(i)

A = 2# * L1 * L3 * Sin(s1)

B = 2# * L3 * (L1 * Cos(s1) - L4)

C = L2 * L2 - L1 * L1 - L3 * L3 - L4 * L4 + 2# * L1 * L4 * Cos(s1)

deta1 = A * A + B * B - C * C

If deta1 < 0 Then flag = 1: Exit For

s3 = 2# * Atn((A + M * Sqr(deta1)) / (B - C))

e3(i) = 180# / PI * s3

D = 2# * L1 * L2 * Sin(s1)

E = 2# * L2 * (L1 * Cos(s1) - L4)

F = L1 * L1 + L2 * L2 + L4 * L4 - L3 * L3 - 2# * L1 * L4 * Cos(s1)

deta2 = D * D + E * E - F * F

If deta2 < 0 Then flag = 1: Exit For

s2 = 2# * Atn((D + M * Sqr(deta2)) / (E - F))

e2(i) = 180# / PI * s2

w3 = w1 * L1 * Sin(s1 - s2) / (L3 * Sin(s3 - s2))

u3(i) = w3

w2 = -w1 * L1 * Sin(s1 - s3) / (L2 * Sin(s2 - s3))

u2(i) = w2

d3(i) = (w1 * w1 * L1 * Cos(s1 - s2) + w2 * w2 * L2 - _

w3 * w3 * L3 * Cos(s3 - s2)) / (L3 * Sin(s3 - s2))

d2(i) = (-w1 * w1 * L1 * Cos(s1 - s3) + w3 * w3 * L3 - _

w2 * w2 * L2 * Cos(s2 - s3)) / (L2 * Sin(s2 - s3))

MsgBox ""

Print Format(i, "@@@");

Print Format(Round(e1(i), 1), String(6, "@"));

Print Format(Round(e2(i), 3), String(9, "@"));

Print Format(Round(e3(i), 3), String(9, "@"));

Print Format(Round(u2(i), 3), String(9, "@"));

Print Format(Round(u3(i), 3), String(8, "@"));

Print Format(Round(d2(i), 3), String(9, "@"));

Print Format(Round(d3(i), 3), String(9, "@"))

Next i

If (flag = 1) Then Print vbCrLf & "Data Error,check again"

Me.Cls

Me.BackColor = QBColor(9)

Me.Line (140, 100)-(550, 100)

Me.Line (140, 240)-(550, 240)

Me.Line (140, 380)-(550, 380)

Me.Line (140, 40)-(140, 440)

Me.Line (500, 40)-(500, 440)

x1 = e1(0): y1 = 0.4 * e3(0)

For i = 0 To Num

x2 = e1(i): y2 = 0.4 * e3(i)

Me.Line (140 + x1, 100 - y1)-(140 + x2, 100 - y2)

x1 = x2: y1 = y2

Next i

x1 = e1(0): y1 = 4 * u3(0)

For i = 0 To Num

x2 = e1(i): y2 = 4 * u3(i)

Me.Line (140 + x1, 240 - y1)-(140 + x2, 240 - y2)

x1 = x2: y1 = y2

Next i

x1 = e1(0): y1 = 0.5 * d3(0)

For i = 0 To Num

x2 = e1(i): y2 = 0.5 * d3(i)

Me.Line (140 + x1, 380 - y1)-(140 + x2, 380 - y2)

x1 = x2: y1 = y2

Next i

MsgBox ""

End

End Sub

相关推荐

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

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
©️2022 CSDN 皮肤主题:游动-白 设计师:我叫白小胖 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值