Microsoft KB Archive/145695

= PRB: Error Converting String to Numeric Value When Using "%" =

Article ID: 145695

Article Last Modified on 5/7/2003

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Learning Edition
 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 5.0 Professional Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 5.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition
 * Microsoft Visual Basic 4.0 Standard Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 Enterprise Edition
 * Microsoft Visual Basic for Applications 5.0

-



This article was previously published under Q145695



SYMPTOMS
When converting a string that represents a percentage with the percent (%) character, you receive the following error:

Run-time error '13':

Type Mismatch

You may receive this error using the CDbl, CSng, CCur, or CDec conversion functions.



Steps to Reproduce the Problem
 Start a new project in Visual Basic. In the Debug Window (or Immediate Window), type the following and press the ENTER key:

?CDbl("12.00%")

 You receive the run-time error "Type Mismatch". To correctly convert "12.00%" to a numeric representation, type the following in the Debug Window and press the ENTER key:

?CDbl(Format("12.00%", "0.00"))

 You should receive the results 0.12 as expected.

Additional query words: kbVBp400 kbVBp500 kbVBp600 kbVBp kbdsd kbDSupport kbVBA

Keywords: kbprb KB145695

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.