Keeping a number six digits

Posted on 2003-02-20
Medium Priority
Last Modified: 2012-05-04
I have a string submitted from the user. The string represents a number that is 6 chars long and will contain leading zeros and always greater than 1000. Ex: 006666. This string is converted to long in my database. Conversion process removes leading 0's. How can I convert it to the original format to execute queries on the ODBC connection? I'm currently using the following formula and thought there may be a mathematical solution possibly by division or a VB function.
sPID = "006666"
Select case clng(sPID)
   case 1000 to 9999
        sPRODID = "00" & SPID
   case 10000 to 99999
        sPRODID = "0" & SPID
end select
Question by:drodela
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 101

Accepted Solution

mlmcc earned 200 total points
ID: 7988257

sPRODID = Format(cstr(sPID),"000000")


Expert Comment

ID: 7990247
something like mimicc:

sPORDID = left("000000" & pid,6)

Author Comment

ID: 8167519
This is what I needed. Thanks.
LVL 101

Expert Comment

ID: 8170492
Glad to help


Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Six Sigma Control Plans
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question