473,322 Members | 1,911 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Type Mismatch using Format()

OK, newbie here - I am trying to figure how how in the heck I can use
the Format command to pre-format integers to display a fixed length
supplimenting leading zeros when needed.

According to the RTFM rigors I have been going through all morning, I
just give Format an expression with the first value being either
numeric or string. But when I try either it spits out a type mismatch
error. I have tried it with the recordset from the SQL, with a local
variable and with a constant value in both string and numeric. I have
tried using various type conversions like CDec or CInt or CStr - I
keep getting the same error. I have tried removing all the optional
parameters and just giving it a value like:

Format(123)

or

Format("123")

I am beginning to realize why I avoided microsoft languages and
platforms for so long - I am about to TTFM (throw the fekkin manual)

Help!

Kathy Lynn
Jul 19 '05 #1
4 10376
CJM
Is there a Format() function in VBScript? I couldnt see one...

See
http://msdn.microsoft.com/library/de...ifunctions.asp

Of the top of my head, you could do something similar to the following:
sPaddedString = Left('00000', 5-Len(iMyInteger)) & iMyInteger 'For 5-chr
strings/numbers

[PS. I haven't actually tested this!]

Chris
Jul 19 '05 #2
> OK, newbie here - I am trying to figure how how in the heck I can use
the Format command to pre-format integers to display a fixed length
supplimenting leading zeros when needed.


There is no format() in VBScript. For padding integers, see
http://www.aspfaq.com/2300
Jul 19 '05 #3
"Aaron Bertrand - MVP" <aa***@TRASHaspfaq.com> wrote in message news:<Oi**************@TK2MSFTNGP12.phx.gbl>...
OK, newbie here - I am trying to figure how how in the heck I can use
the Format command to pre-format integers to display a fixed length
supplimenting leading zeros when needed.


There is no format() in VBScript. For padding integers, see
http://www.aspfaq.com/2300


oh - hmmm

Then perhaps I am more newbie then I thought - I did a web search on
google for '"visual basic" asp "format function"' and found the
following link. So VBScript does 'not' inherit all visual basic
functions?

http://msdn.microsoft.com/library/de...gesinvbnet.asp

KL
Jul 19 '05 #4
Correct, VBScript is more or less a subset of Visual Basic.

http://tech.irt.org/articles/js117/

http://www.soldierx.com/books/Teach%...0Days/ch20.htm


"Catherine Lynn Smith" <kl*****@hotmail.com> wrote in message
news:5f**************************@posting.google.c om...
"Aaron Bertrand - MVP" <aa***@TRASHaspfaq.com> wrote in message news:<Oi**************@TK2MSFTNGP12.phx.gbl>...
OK, newbie here - I am trying to figure how how in the heck I can use
the Format command to pre-format integers to display a fixed length
supplimenting leading zeros when needed.


There is no format() in VBScript. For padding integers, see
http://www.aspfaq.com/2300


oh - hmmm

Then perhaps I am more newbie then I thought - I did a web search on
google for '"visual basic" asp "format function"' and found the
following link. So VBScript does 'not' inherit all visual basic
functions?

http://msdn.microsoft.com/library/de...gesinvbnet.asp
KL

Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: middletree | last post by:
I've been messing with this for hours, and have been to various sites, including Aaron's site, and am truly stumped. The short version: in SQL Server, the 4 fields in question are datetime. I...
4
by: Mike | last post by:
I am getting a type mismatch error when I do a bulk insert. ---Begin Error Msg--- Server: Msg 4864, Level 16, State 1, Line 1 Bulk insert data conversion error (type mismatch) for row 1, column...
4
by: DS | last post by:
I have a field where the format is set to currency, However I want to use a Calculator type Number Pad to Enter the Dollar Amounts in gthe field. I have this part figured out but I keep getting a...
1
by: amitbadgi | last post by:
I am getting the following error while converting an asp application to asp.net Exception Details: System.Runtime.InteropServices.COMException: Data type mismatch in criteria expression. ...
19
by: Lysander | last post by:
I have written a query that takes three integers representing day,month and year, forms a date from them and compares this date to the date the record was entered and returns any records where the...
7
by: Mike | last post by:
Type Mismatch error I recieve a type mismatch error on the following line of code which is based on a specific date. It does NOT break on all records only "some". The dates for the records...
1
by: gokulraj84 | last post by:
This is my Coding. Application newApp = new Application(); // Response. // specifying the Source & Target file names // c:\\abc\\Source.doc; object Source...
1
nurikoAnna
by: nurikoAnna | last post by:
I am having troubled debugging with my codes...It always gets an error "TYPE MISMATCH" Below is my code in my frmApplicantsEntry: ...
1
nurikoAnna
by: nurikoAnna | last post by:
I am having troubled debugging with my codes...It always gets an error "TYPE MISMATCH" Below is my code in my frmApplicantsEntry: __________________________________________________...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.