ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   x = textbox1.value (somethings wrong) (https://www.excelbanter.com/excel-programming/293492-x-%3D-textbox1-value-somethings-wrong.html)

CAA[_18_]

x = textbox1.value (somethings wrong)
 
I'm at a loss here. What have i done wrong?

put in the amount in a textbox and the image sizes, but if i want t
add something to the size like 2 other variables then something goe
wrong

Hgt = textbox1.value
Image1.Height = Hgt - TT - TV

Should i be coverting the value to a long type?
Thanks for looking
CA

--
Message posted from http://www.ExcelForum.com


Carlos[_2_]

x = textbox1.value (somethings wrong)
 
You need convert Hgt

e.g.
Hgt = Val(textbox1.value)
Image1.Height = Hgt - TT - TV

"CAA " wrote in message
...
I'm at a loss here. What have i done wrong?

put in the amount in a textbox and the image sizes, but if i want to
add something to the size like 2 other variables then something goes
wrong

Hgt = textbox1.value
Image1.Height = Hgt - TT - TV

Should i be coverting the value to a long type?
Thanks for looking
CAA


---
Message posted from http://www.ExcelForum.com/




Bob Phillips[_6_]

x = textbox1.value (somethings wrong)
 
It certainly won't hurt.

What is in TT & TV?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"CAA " wrote in message
...
I'm at a loss here. What have i done wrong?

put in the amount in a textbox and the image sizes, but if i want to
add something to the size like 2 other variables then something goes
wrong

Hgt = textbox1.value
Image1.Height = Hgt - TT - TV

Should i be coverting the value to a long type?
Thanks for looking
CAA


---
Message posted from http://www.ExcelForum.com/




CAA[_19_]

x = textbox1.value (somethings wrong)
 
Still not right?

I run the form and enter, say 900 in the text box. When the value of T
& TV = 0 (just text positions if they exist) all is ok. Then when TT i
not 0 all go's to pot.
Says cannot set height, so i look at the value of HGT and it is 0, wh
would it be 0?

using
Hgt = Val(textbox1.value)

I have declared Hgt, TT and TV as Long types.
should i be decalring another type to hold the result of Hgt - TT
TV?

It seems a simple thing, why is it thrashing my head!?

Thanks for looking
CA

--
Message posted from http://www.ExcelForum.com


Bob Phillips[_6_]

x = textbox1.value (somethings wrong)
 
Carlos,

That doesn't surprise me because if the textbox is a number, even though
textbox returns a string it can ad correctly.

You didn't answer my question about what was in TT and TV. If the total of
TT and Tv exceeds the textbox value then you will get an error. You should
trap the error with

Hgt = Val(TextBox1.Value)
If Hgt (TT + TV) Then
Image1.Height = Hgt - (TT + TV)
Else
MsgBox "Invalid height for image"
With TextBox1
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End With
End If


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"CAA " wrote in message
...
Still not right?

I run the form and enter, say 900 in the text box. When the value of TT
& TV = 0 (just text positions if they exist) all is ok. Then when TT is
not 0 all go's to pot.
Says cannot set height, so i look at the value of HGT and it is 0, why
would it be 0?

using
Hgt = Val(textbox1.value)

I have declared Hgt, TT and TV as Long types.
should i be decalring another type to hold the result of Hgt - TT -
TV?

It seems a simple thing, why is it thrashing my head!?

Thanks for looking
CAA


---
Message posted from http://www.ExcelForum.com/




CAA[_20_]

x = textbox1.value (somethings wrong)
 
Thanks Bob,
I had done the error checking in an erlier piece of code by setting Hg
to 100 as a minimum as TT + VT could only be 90, however your commen
made me think more about what i'd done and basically i'm a plonker
again..
I had put this before an End If statement, so it was not even take
into account. Oh, the humiliation

Thanks for Alleviating the few brain Cells i have left, they really d
appreciate it & are going to celebrate in a few hours by playing
little game of Russian Vodka roulette in your honour.

CA

--
Message posted from http://www.ExcelForum.com


Bob Phillips[_6_]

x = textbox1.value (somethings wrong)
 
CAA,

Glad to help. I'll have a Tequila to share it with you!

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"CAA " wrote in message
...
Thanks Bob,
I had done the error checking in an erlier piece of code by setting Hgt
to 100 as a minimum as TT + VT could only be 90, however your comment
made me think more about what i'd done and basically i'm a plonker,
again..
I had put this before an End If statement, so it was not even taken
into account. Oh, the humiliation

Thanks for Alleviating the few brain Cells i have left, they really do
appreciate it & are going to celebrate in a few hours by playing a
little game of Russian Vodka roulette in your honour.

CAA


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 10:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com