Carrying a value over and adding .1

  • Thread starter Thread starter Anthony Viscomi
  • Start date Start date
A

Anthony Viscomi

I have the following:

Const cQuote = ""
Const cQuotePos = ""
Me.Base_Price.DefaultValue = cQuote & Me.Base_Price.Value & cQuote
Me.Position.Value = cQuotePos & Me.Position.Value & cQuote + 0.1

The 1st portion works fine; but the 2nd doesn't seem to like me adding the
..1 value to it. The control (Positon) is numeric.

Any thoughts?
Anthony
 
Const cQuote = ""
Const cQuotePos = ""

Why two constants with the same value? And the same value as the inbuilt
vbNullStr?
Me.Base_Price.DefaultValue = cQuote & Me.Base_Price.Value & cQuote

Concatenating the strings don't seem to do anything.
Me.Position.Value = cQuotePos & Me.Position.Value & cQuote + 0.1

This will cause a datatype error: everything before the + has to be a
string value (albeit that the constants are not doing anything), and the
value afterwards is a numeric. This is legal:

me.position.value = me.position.value & "0.1"

but I don't really understand what it would be for.


Perhaps you could let us know what you are trying to achieve?

Tim F
 
Anthony said:
I have the following:

Const cQuote = ""
Const cQuotePos = ""
Me.Base_Price.DefaultValue = cQuote & Me.Base_Price.Value & cQuote
Me.Position.Value = cQuotePos & Me.Position.Value & cQuote + 0.1

The 1st portion works fine; but the 2nd doesn't seem to like me adding the
.1 value to it. The control (Positon) is numeric.

Your constants are both declared as zero length strings
(ZLS) so they have no real effect in setting the
DefaultValue. Since the DefaultValue property is a string
valued property, VBA will automatically convert a numeric
value to a string and extra quotes are not needed.
Me.Base_Price.DefaultValue = Me.Base_Price.Value

However, in the position line, the simple act of using the &
operator forces VBA to convert the value to a string so the
+ also operates as a concatenation, not an addition. Just
change it to:
Me.Position.Value = Me.Position.Value + 0.1
 
Back
Top