I’m porting some VBA code into C#, and at the beginning of one of the functions to port is the line:
Dim sCA;
Is there any way of finding out what I should store this as in C#? I need to pull a string out of it, but the methods from the library I’m using returns a number, which then confuses the compiler when I try to use IndexOf(). When I check the parameters list for the function used to set it, I see this:
ReadValue([DataPoint As String], [intErrorMode As Integer = 0])
Seeing as there is no ReadValue() in C#, I’m a little stuck at the moment, is anything you can throw at me will be much appreciated.
EDIT: Apologies for the mess that went on down there, here’s the full function:
Sub CheckForPin(sSTB As String, sPIN As String, iSetTopBoxID As Integer)
Dim sCA_PopUp
sCA_PopUp = ReadValue("Fix32." & SCADA_NAME & "." & sSTB & CStr(iSetTopBoxID) & "_POPUP_CA" & ".F_CV", 1)
If InStr(1, UCase(sCA_PopUp), "PIN PROTECTED") <> 0 Then
WriteValue sPIN, "Fix32." & SCADA_NAME & "." & sSTB & CStr(iSetTopBoxID) & "_MULTIPLE_CMD" & ".A_CV", 1
End If
Exit Sub
Given that the original programmers prefixed all variables with a type indicator (in this case, the “s”), it is safe to deduce that it is indeed a string. Also, I’m not sure if Dim sCA_PopUp and Dim sCA are referring to the same variable and you just didn’t catch this, but if so, from the heavy concatenation going on, there is further evidence that it should be interpreted as a string. When you convert this to C#, use StringBuilder instead.