adam_pedley
asked on
Overloading Functions
Hi
Is there any obvious flaws with my code below, I have created a DLL with two functions with an overload
Public Function Config(ByVal strIOAddress As String) As String
'Function: This sets settings on the ADAM Module
'%AANNTTCCFF
'AA = Address in hex
'NN = Address to set the ADAM Module to
'TT = Type code Always = 40 for ADAM Modules 4050-68
'CC = Baud Rate
' 03 1200bps
' 04 2400bps
' 05 4800bps
' 06 9600bps
' 07 19.2kbps
' 08 38.4Kbps
' 09 57.6Kbps
' 0A 115.2Kbps
'
' FF = Checksum Status and Protocol
'
' Bits Function
' 0 Always set to 0
' 1 Always set to 0
' 2 Selection of Protocol (0 = Advantech(ASCII), 1 = Modbus)
' 3 Always set to 0
' 4 Always set to 0
' 5 Always set to 0
' 6 Selection Checksum (0 = Disabled, 1 = Enabled)
' 7 Always set to 0
Dim strPacket As String
Dim checksumprotocol As String = Bin2Hex("00" & Protocol & "000" & Checksum & "0")
strPacket = "%" & Address & strIOAddress & TypeCode & BaudRate & checksumprotocol
MsgBox(strPacket)
Return strPacket
End Function
Public Overloads Function Configuration() As String
'LOOK IN ABOVE FUNCTION FOR DETAILS
MsgBox("hello")
Return Config(Address)
End Function
Public Overloads Function Configuration(ByVal strIOAddress As String) As String
'LOOK IN ABOVE FUNCTION FOR DETAILS
MsgBox("hello")
Return Config(strIOAddress)
End Function
This just should return a string
I reference the DLL and call the code like this in another program
Private adammodule As New ADAM_DLL.CommandSet()
Dim packet As String = adammodule.Configuration()
MsgBox(packet)
The msgbox(packet) comes back as nothing and neither of the msgbox's in the DLL appear
I can successfully call other functions in the DLL and they work fine
And yes i have updated the DLL so that the program has the most up to date version of it
Thanks
Adam
Is there any obvious flaws with my code below, I have created a DLL with two functions with an overload
Public Function Config(ByVal strIOAddress As String) As String
'Function: This sets settings on the ADAM Module
'%AANNTTCCFF
'AA = Address in hex
'NN = Address to set the ADAM Module to
'TT = Type code Always = 40 for ADAM Modules 4050-68
'CC = Baud Rate
' 03 1200bps
' 04 2400bps
' 05 4800bps
' 06 9600bps
' 07 19.2kbps
' 08 38.4Kbps
' 09 57.6Kbps
' 0A 115.2Kbps
'
' FF = Checksum Status and Protocol
'
' Bits Function
' 0 Always set to 0
' 1 Always set to 0
' 2 Selection of Protocol (0 = Advantech(ASCII), 1 = Modbus)
' 3 Always set to 0
' 4 Always set to 0
' 5 Always set to 0
' 6 Selection Checksum (0 = Disabled, 1 = Enabled)
' 7 Always set to 0
Dim strPacket As String
Dim checksumprotocol As String = Bin2Hex("00" & Protocol & "000" & Checksum & "0")
strPacket = "%" & Address & strIOAddress & TypeCode & BaudRate & checksumprotocol
MsgBox(strPacket)
Return strPacket
End Function
Public Overloads Function Configuration() As String
'LOOK IN ABOVE FUNCTION FOR DETAILS
MsgBox("hello")
Return Config(Address)
End Function
Public Overloads Function Configuration(ByVal strIOAddress As String) As String
'LOOK IN ABOVE FUNCTION FOR DETAILS
MsgBox("hello")
Return Config(strIOAddress)
End Function
This just should return a string
I reference the DLL and call the code like this in another program
Private adammodule As New ADAM_DLL.CommandSet()
Dim packet As String = adammodule.Configuration()
MsgBox(packet)
The msgbox(packet) comes back as nothing and neither of the msgbox's in the DLL appear
I can successfully call other functions in the DLL and they work fine
And yes i have updated the DLL so that the program has the most up to date version of it
Thanks
Adam
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Address was initialised elsewhere
I found the problem, even though i remove the reference to the DLL in vb .net then readded it after a recompile of the DLL it still didnt add the new one
So it was a stupid mistake
Thanks anyway
I found the problem, even though i remove the reference to the DLL in vb .net then readded it after a recompile of the DLL it still didnt add the new one
So it was a stupid mistake
Thanks anyway
ASKER
I would only step debug if some strange things were happening, but a msgbox to quickly find out if it gets to that point in the code is alot quicker
Public Overloads Function Configuration() As String
'LOOK IN ABOVE FUNCTION FOR DETAILS
MsgBox("hello")
Return Config(Address) ' <-- ding! ding! ding!
End Function
Where did Address come from? Did you initialize it anywhere?
Have fun.