Hold Decimals in String

Hold Decimals in String

SteveK88
Advocate Advocate
738 Views
6 Replies
Message 1 of 7

Hold Decimals in String

SteveK88
Advocate
Advocate

Hi,

I am passing WorkPoint locations to a text file.

When the values get passed across I get whole numbers and decimals.  I'd like to keep all with 2 place decimals. 

 

Simplified,

 

roundedClosest = CStr(Round(5, 2))

Results in a text value of 5

Preference is to be 5.00

 

Any ideas?  

0 Likes
Accepted solutions (1)
739 Views
6 Replies
Replies (6)
Message 2 of 7

bradeneuropeArthur
Mentor
Mentor

in:

  • Ilogic?
  • VBA?
  • VB.net?
  • or else?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 7

bradeneuropeArthur
Mentor
Mentor

With VBA:

Public Sub Stringdec()

Dim a As Variant
a = 5.1233

Dim b As Variant
b = VBA.Round(a, 0)

'MsgBox b & ".00"

Dim e As Variant
e = b & ".00"

MsgBox e
End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 4 of 7

SteveK88
Advocate
Advocate

I'd like to stay in iLogic.


@bradeneuropeArthur wrote:

in:

  • Ilogic?
  • VBA?
  • VB.net?
  • or else?

 

0 Likes
Message 5 of 7

SteveK88
Advocate
Advocate

Thanks, but this will change all decimals numbers to whole numbers.  I have a mix,

number from Inventor WorkPoints can be 5, or 5.123458.  Looking to get two place decimals in my string at all times.

5.00, 5.12 - preferred

 

Presently using iLogic rounding I get,

5, 5.12 - not preferred

 

I would like to stay in iLogic.

0 Likes
Message 6 of 7

lmc.engineering
Advocate
Advocate
Accepted solution

Hi @SteveK88

 

This should work for you.

 

Version:1.0 StartHTML:00000145 EndHTML:00000623 StartFragment:00000294 EndFragment:00000591 StartSelection:00000294 EndSelection:00000294SyntaxEditor Code Snippet

myParameter = Double.Parse(x1).ToString("0.00") 
Message 7 of 7

lmc.engineering
Advocate
Advocate

sorry, the x1 in brackets is your input

0 Likes