definitions

Dryver14

Well-known Member
Joined
Mar 22, 2010
Messages
2,396
Thanks for the patience over these questions. The answers really are helping me learn.

Could someone please clarify why "Monthly is dim as string when the return is a value? Thanks.



Dim Monthly as string

Monthly = InputBox("Enter your monthly salary:")
 
Last edited:

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
If it was declared a a number (eg Long or Double) & the user clicked cancel you'd get a "Type Mismatch Error"
 
Upvote 0
Thanks Fluff, that bit makes sense I am still a little unsure why the dim string accepts a number though
 
Upvote 0
I went looking for the answer and found this

[h=2]Strings[/h]
String data is non-numerical, and is used to store characters and words. All strings consist of characters enclosed within double quotation marks. The string data can include numbers and other numerical symbols but will be treated as text.
 
Upvote 0
Whilst it treats a numerical string as text, you can still do some mathematical calculations. Try
Code:
Sub chk()
Dim a As String
a = InputBox("enter a number")
MsgBox a + 10 & vbLf & a * 10 & vbLf & a + a
End Sub
Whilst the first 2 lines of the msgbox show the calculated result, the last line is a concatenation
 
Upvote 0
Thanks Fluff,

I really appreciate your input, Up to now all of my excel and vba skills have been project driven so I (sort of) learned what I needed to and moved on.

Now I have started at the beginning and page by page am making my way to the end of the book I am staggered by how little I know LOL
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,270
Members
452,628
Latest member
dd2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top