Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Declaration?

Hello,

I need declaration variable like this:

dim example as ???
example = 155
msgbox example
------------------------------------
And I need this result: 000155
------------------------------------
example = example + 1000
------------------------------------
And I need this result: 001155
------------------------------------

in range I cen use Selection.NumberFormat = "000000", but how its work when
I want use this in variable.

Thanks Tom


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Declaration?

Will your number scheme (including leading zeroes) always be 6 digits
long? What is the smallest and largest scheme of numbers that you can
possible have?


Rollin


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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Declaration?

msgbox Format(example,"000000")

--
Regards,
Tom Ogilvy

"TJF" wrote in message
...
Hello,

I need declaration variable like this:

dim example as ???
example = 155
msgbox example
------------------------------------
And I need this result: 000155
------------------------------------
example = example + 1000
------------------------------------
And I need this result: 001155
------------------------------------

in range I cen use Selection.NumberFormat = "000000", but how its work

when
I want use this in variable.

Thanks Tom




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Declaration?

5 digits is enough for me. I need it for list of items.
example: PS-03-00001

So i need something like:

MyNumber = 1
result = "PS-03-" & MyNumber
msgbox result (or Range("A1") = result)
-------------------------------------
PS-03-00001
-------------------------------------

Thanks

"Rollin_Again" píše v diskusním
příspěvku ...
Will your number scheme (including leading zeroes) always be 6 digits
long? What is the smallest and largest scheme of numbers that you can
possible have?


Rollin


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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default Declaration?

Here is one idea.

Sub Demo()
Dim n, Result
n = 1
Result = Format$(n, """PS-03-""00000")
MsgBox Result
End Sub


If it's used in a loop over many cells, perhaps make the format a constant.

Sub Demo2()
Dim n, Result
Const Fmt As String = """PS-03-""00000"
n = 123

Result = Format$(n, Fmt)
MsgBox Result
End Sub

HTH
--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"TJF" wrote in message
...
5 digits is enough for me. I need it for list of items.
example: PS-03-00001

So i need something like:

MyNumber = 1
result = "PS-03-" & MyNumber
msgbox result (or Range("A1") = result)
-------------------------------------
PS-03-00001
-------------------------------------

Thanks

"Rollin_Again" píše v diskusním
příspěvku ...
Will your number scheme (including leading zeroes) always be 6 digits
long? What is the smallest and largest scheme of numbers that you can
possible have?


Rollin


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







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Declaration?

Hi Tom

Long ! Use Long for integer numbers and Double for numbers that may or may
not contain decimals.

Dim L As Long
L = 155
MsgBox Format(L,"000000")
L = L + 1000
MsgBox Format(L,"000000")

--
HTH. Best wishes Harald
Followup to newsgroup only please

"TJF" skrev i melding
...
Hello,

I need declaration variable like this:

dim example as ???
example = 155
msgbox example
------------------------------------
And I need this result: 000155
------------------------------------
example = example + 1000
------------------------------------
And I need this result: 001155
------------------------------------

in range I cen use Selection.NumberFormat = "000000", but how its work

when
I want use this in variable.

Thanks Tom




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Array Declaration. apis Excel Discussion (Misc queries) 1 November 5th 11 01:53 PM
Workbook Declaration Varne Excel Discussion (Misc queries) 3 April 29th 08 09:49 AM
VBA - variable declaration Jeff Excel Discussion (Misc queries) 3 January 9th 08 12:45 PM
public declaration kevin Excel Programming 1 December 6th 03 07:00 PM
Variable Declaration?? Tom Ogilvy Excel Programming 1 August 8th 03 06:45 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright Š2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"