谁帮我把这两个VB6的代码转换为C#的.分不够再送,谢谢!

云海玉弓缘 2009-06-09 10:25:24

Private Sub Timer1_Timer()
On Error Resume Next
If Text2 < 0 Then
Text2 = 0
End If
If Text2 > 100 Then
Text2 = 100
End If
gain = Val(Text2)
If Text3 < 0 Then
Text3 = 0
End If
If Text3 > 120 Then
Text3 = 120
End If
reset = Val(Text3)
If Text4 < 0 Then
Text4 = 0
End If
If Text4 > 120 Then
Text4 = 120
End If
rate = Val(Text4)

If pv < 3101 Then
pv = pv + invalve
End If
If pv > 0 Then
pv = pv - outvalve
End If
Text1.Text = pv
error = sp - pv
Label30.Caption = error
Label38.Caption = supply
tank
If stability = 1 Then
watersupply
invalve = (HScroll1.Value * (supply / 100)) / 60
End If
If mode = 1 Then
pidloop
End If

' 画曲线PV过程变量
' Graph the PV, Process Variable
Picture1.Cls
pvgraph(100) = pv
For x = 0 To 99
pvgraph(x) = pvgraph(x + 1)
Picture1.PSet (x, 3000 - (pvgraph(x)))
Next x

' Display the SP line (yellow)
Picture1.Line (0, 3000 - sp)-(100, 3000 - sp), vbYellow

' Graph the OUTPUT VALVE position
Picture2.Cls
outgraph(100) = outvalve
For x = 0 To 99
outgraph(x) = outgraph(x + 1)
Picture2.PSet (x, 100 - (outgraph(x) * 2))
Next x
End Sub

'********************************************************

Private Sub tank()
If HScroll1.Value > 0 Then
Shape7.FillStyle = 0
Shape8.FillStyle = 0
Shape9.FillStyle = 0
Else: Shape7.FillStyle = 1
Shape8.FillStyle = 1
Shape9.FillStyle = 1
End If
If pv > -1 Then
Shape1(0).Top = (3100 - pv) + 1030
Shape1(0).Height = pv
End If
If (pv > 0) Or (HScroll1.Value > 0) Then
Shape10.FillStyle = 0
Else: Shape10.FillStyle = 1
End If
If (HScroll2.Value > 0) And (pv > 0) Then
Shape11.FillStyle = 0
Else: Shape11.FillStyle = 1
End If
End Sub

'********************************************************

Private Sub watersupply()
Randomize
s1 = Int(Rnd(1) * 20 + 1)
Randomize
s2 = Int(Rnd(1) * 1000 + 1)
If s2 < 100 Then
supply = supply + s1
End If
If s2 > 900 Then
supply = supply - s1
End If
If supply < 500 Then
supply = 500
End If
If supply > 2500 Then
supply = 2500
End If

End Sub

'********************************************************

Private Sub pidloop()
dfilter = 10 ' Filter value to scale down derivative effect.
inputd = pv + (inputlast - pv) * (rate / 60)
inputlast = pv
inputdf = inputdf + (inputd - inputdf) * dfilter / 60
output = (sp - inputdf) * (gain / 100) + feedback
If output > 100 Then ' clamp output valve between 0 and 100%
output = 100
End If
If output < 0 Then
output = 0
End If
HScroll2.Value = 100 - output ' Change slider value (AUTO MODE)
Picture4.Width = HScroll2.Value * 20
Label14.Caption = HScroll2.Value
feedback = feedback - (feedback - output) * reset / 60
End Sub


谁能帮我把上面几个VB6的函数转换为c#的啊
一个timer,还有几个函数.
在线等(在线转换的不太满意) 谢谢~
...全文
40 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
云海玉弓缘 2009-06-09
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 hztltgg 的回复:]
你的代码主要问题是
Text2 之类的用了默认属性,.net里不能用,要写text2.text,Label30.Caption 也不行,没有caption属性来,都是text属性

绘图函数变化也很大,line,pset都不能用了,有专门的cgi+函数

Shape1(0)是形状控件数组么?控件数组也没有了,直接用数组保存了,而且形状控件也没有了,虽然后来又加了Visual Basic PowerPacks,里面有,不过用起来也不一样

基本上你的代码改不了,改成vb.net都困难,还是…
[/Quote]

哦哦 我不太懂VB, 看了你的话我觉得也没戏了,还是按这个功能重新写吧...
云海玉弓缘 2009-06-09
  • 打赏
  • 举报
回复
C#里没有Shape了,关于这一部分的可以注释掉先不用转了,其他的有大虾能帮我搞下吗
hztltgg 2009-06-09
  • 打赏
  • 举报
回复
你的代码主要问题是
Text2 之类的用了默认属性,.net里不能用,要写text2.text,Label30.Caption 也不行,没有caption属性来,都是text属性

绘图函数变化也很大,line,pset都不能用了,有专门的cgi+函数

Shape1(0)是形状控件数组么?控件数组也没有了,直接用数组保存了,而且形状控件也没有了,虽然后来又加了Visual Basic PowerPacks,里面有,不过用起来也不一样

基本上你的代码改不了,改成vb.net都困难,还是重新写吧,按原来的需求一个个在.net平台下解决

cpio 2009-06-09
  • 打赏
  • 举报
回复
看起来不少,没半小时估计转不出来

Profiteerchen 2009-06-09
  • 打赏
  • 举报
回复
沙发

110,571

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧