473,395 Members | 1,689 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,395 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 10382
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.