目的:
在wincc中,需要大量的数据来进行软件仿真,因此需要使用脚本实现产生随机数的功能。
脚本代码:
全局脚本:
Function MyRnd(min,max)
MyRnd=Rnd*(max-min+1)+min '在(min,max)之间取随机数
End Function
按钮脚本
Sub OnClick(Byval Item)
'随机产生0-1000内的数据
HMIRuntime.Tags("T_Power").Write MyRnd(0,1000)
HMIRuntime.Tags("T_Count").Write MyRnd(0,1000)
End Sub