0

Having some issues after running a tool to convert the VB6.Format() to VS 2008 code. We had this statement:

VB6.Format(InVariable, szFormatMask))

That was converted to this:

InVariable.ToString(szFormatMask)

The issue being that now, when we call our function it has having the issue that it cannot convert a String = "" to an Integer value. InVariable is an object, and szFormatMask is a string in our function. Do you have any suggestions as to not cause this issue any longer?

user2178477
  • 47
  • 2
  • 11

1 Answers1

0

Add a check for the empty string and change accordingly:

If szFormatMask = "" Then szFormatMask = "G"
Return InVariable.ToString( szFormatMask )

The 'G' format-string value is special in that is specifies the output is the "General" number format.

(A brief word on code-style: please avoid Hungarian notation, e.g. the In and sz prefixes, and name local variables and parameters using lowercase camelCase, as uppercase CamelCase is reserved for type members like methods and properties.

Dai
  • 141,631
  • 28
  • 261
  • 374