110,501
社区成员
发帖
与我相关
我的任务
分享
//================================================================================================================
//VB6.0事件处理 OnReceive()如下,收发数据正常。
//Private Sub Command1_Click()
//FinsMsg1.sendFinsCommand 0, 1, 0, "0101820064000002"
//End Sub
//Private Sub FinsMsg1_OnReceive()
//Dim net As Integer, node As Integer, unit As Integer
//Text1.Text = FinsMsg1.receiveMessage(net, node, unit, vbString)
//End Sub
//================================================================================================================
private void button1_Click(object sender, EventArgs e)
{
axFinsMsg1.sendFinsCommand(0, 1, 0, "0101820064000002");
}
private void axFinsMsg1_OnReceive(object sender, EventArgs e)
{
//public virtual object receiveMessage(ref short netID, ref short nodeID, ref short unitID, object messageType)
//AxFINSMSGCTLLib.AxFinsMsg 的成员
short a=0,b=0,c=0;
object temp=new object();
textBox1.Text = axFinsMsg1.receiveMessage(ref a,ref b,ref c,temp);
//错误 1 无法将类型“object”隐式转换为“string”。存在一个显式转换(是否缺少强制转换?)
}
Definition Function readArea(Type As SysmacCS1_DataArea_Constants, Offset As Long, Size As Long, RetValType)
Explanation Reads the PLC continuous I/O memory area.
Parameters Type Specifies the area type.
Offset Specifies the area offset.
Size Specifies the area size (number of words).
RetValType Specifies the return value type: character string, byte array, or Variant array.
Return Value The readArea method returns the read value in the type specified in the fourth parameter, stored as a Variant.
Example 1 - Read the data from DM 0 to 100, and store it in the Variant variable var, with subtype String:
Dim var As Variant
var = SYSMAC_CS11.readArea(plcAreaDM, 0, 100, vbString)
2 - Read 10 words of data starting from DM 0, and store it in the variable var, with subtype Variant array. Store the data from word 5 of the Variant array in the Long variable dm5:
Dim var As Variant
Dim dm5 As Long
var = SYSMAC_CS11.readArea(plcAreaDM, 0, 10, vbVariant Or vbArray)
dm5 = var(6)
Communication Communication is executed.
See Also FINS command 2301
textBox1.Text = axFinsMsg1.receiveMessage(ref a,ref b,ref c,temp.toString());