as I would love to see your app working, why don't you send me your project files to me again. The latest you already did using Qt designer to create your GUI.
I will do the conversion for you for some comments in code to help you to understand the conversion.
What do you think?
CU
Bernd
Henning wrote:Hi
I have partly solved it the "easy" way. By replacing the Typename.Member with Typename_member.
The original
- Code: Select all
Public Dim TxMsg[17] As Byte
Type T_Msg
Type As Byte
ID As Short
tSYSTEM As Byte
unit As Byte
port As Byte
data(7) As Byte
ReplyTo As Short
crc As Short
End Type
'
Type U_SetupMsg
Type As Byte
UType As Byte
UCh As Byte
USys As Byte
Uunit As Byte
UPwr As Byte
USpc As Byte
USpc2 As Byte
USpc3 As Byte
ReplyTo As Short
crc As Short
End Type
Type Shadow
data(8) As Byte
End Type
Public TMsg As T_Msg
Public UTMsg As U_SetupMsg
Public TCmd As T_Msg
Public AckMsg As T_Msg
Public BS As T_Msg
Public InShadow[254] As Shadow
Public UtShadow[254] As Shadow
'Later in a sub next problem arises, TxMsg() is a Byte Array to send as UDP
TxMsg[0] = TCmd.Type ' 1
TxMsg[1] = TCmd.ID \ 256 'Asc("C")
TxMsg[2] = TCmd.ID And &HFF ' 0
TxMsg[3] = TCmd.tSYSTEM
TxMsg[4] = TCmd.unit
TxMsg[5] = TCmd.port
TxMsg[6] = TCmd.data[7]
TxMsg[7] = TCmd.data[6]
TxMsg[8] = TCmd.data[5]
TxMsg[9] = TCmd.data[4]
TxMsg[10] = TCmd.data[3]
TxMsg[11] = TCmd.data[2]
TxMsg[12] = TCmd.data[1]
TxMsg[13] = TCmd.data[0]
TxMsg[14] = TCmd.ReplyTo \ 256
TxMsg[15] = TCmd.ReplyTo And &HFF
CRCTx = 0
For i = 0 To 15 'Calculate CRC
CRCTx = CRCTx + TxMsg[i]
Next
TCmd.crc = CRCTx
TxMsg[16] = TCmd.crc \ 256
TxMsg[17] = TCmd.crc And &HFF
'TxMsg(7) = crcTx And &HFF
'New' version, TxMsg() could be a String (if Mid$() is working?)
- Code: Select all
Public Dim TMsg_Type As Integer
Public Dim TMsg_ID As Integer
Public Dim TMsg_tSYSTEM As Integer
Public Dim TMsg_unit As Integer
Public Dim TMsg_port As Integer
Public Dim TMsg_data[7] As Integer
Public Dim TMsg_ReplyTo As Integer
Public Dim TMsg_crc As Integer
'
Public Dim TCmd_Type As Integer
Public Dim TCmd_ID As Integer
Public Dim TCmd_tSYSTEM As Integer
Public Dim TCmd_unit As Integer
Public Dim TCmd_port As Integer
Public Dim TCmd_data[7] As Integer
Public Dim TCmd_ReplyTo As Integer
Public Dim TCmd_crc As Integer
Public Dim AckMsg_Type As Integer
Public Dim AckMsg_ID As Integer
Public Dim AckMsg_tSYSTEM As Integer
Public Dim AckMsg_unit As Integer
Public Dim AckMsg_port As Integer
Public Dim AckMsg_data[7] As Integer
Public Dim AckMsg_ReplyTo As Integer
Public Dim AckMsg_crc As Integer
Public Dim BS_Type As Integer
Public Dim BS_ID As Integer
Public Dim BS_tSYSTEM As Integer
Public Dim BS_unit As Integer
Public Dim BS_port As Integer
Public Dim BS_data[7] As Integer
Public Dim BS_ReplyTo As Integer
Public Dim BS_crc As Integer
Public Dim UTMsg_Type As Integer
Public Dim UTMsg_UType As Integer
Public Dim UTMsg_UCh As Integer
Public Dim UTMsg_USys As Integer
Public Dim UTMsg_Uunit As Integer
Public Dim UTMsg_UPwr As Integer
Public Dim UTMsg_USpc As Integer
Public Dim UTMsg_USpc2 As Integer
Public Dim UTMsg_USpc3 As Integer
Public Dim UTMsg_ReplyTo As Integer
Public Dim UTMsg_crc As Integer
'
'Type Shadow
Public Dim Shadow_data(8) As Integer
'End Type
'
'*Public TMsg As T_Msg
'*Public UTMsg As U_SetupMsg
'*Public TCmd As T_Msg
'*Public AckMsg As T_Msg
'*Public BS As T_Msg
Public Dim InShadow[254] As Shadow_data
Public Dim UtShadow[254] As Shadow_data
'In same sub as above
TxMsg[0] = TCmd_Type ' 1
TxMsg[1] = TCmd_ID \ 256 'Asc("C")
TxMsg[2] = TCmd_ID And &HFF ' 0
TxMsg[3] = TCmd_tSYSTEM
TxMsg[4] = TCmd_unit
TxMsg[5] = TCmd_port
TxMsg[6] = TCmd_data[7]
TxMsg[7] = TCmd_data[6]
TxMsg[8] = TCmd_data[5]
TxMsg[9] = TCmd_data[4]
TxMsg[10] = TCmd_data[3]
TxMsg[11] = TCmd_data[2]
TxMsg[12] = TCmd_data[1]
TxMsg[13] = TCmd_data[0]
TxMsg[14] = TCmd_ReplyTo \ 256
TxMsg[15] = TCmd_ReplyTo And &HFF
CRCTx = 0
For i = 0 To 15 'Calculate CRC
CRCTx = CRCTx + TxMsg[i]
Next
TCmd_crc = CRCTx
TxMsg[16] = TCmd_crc \ 256
TxMsg[17] = TCmd_crc And &HFF
'I will try Public Dim TxMsg As String * 18
Mid$(TxMsg,1,1) = Chr$(TCmd_Type And &HFF) ' Here comes the (self-documenting) Hex values again. Or what replaces Mid$.
/Henning