473,698 Members | 2,213 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 10402
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***@TRASHasp faq.com> wrote in message news:<Oi******* *******@TK2MSFT NGP12.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*****@hotmai l.com> wrote in message
news:5f******** *************** ***@posting.goo gle.com...
"Aaron Bertrand - MVP" <aa***@TRASHasp faq.com> wrote in message news:<Oi******* *******@TK2MSFT NGP12.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
15813
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 have a page that allows users to type in the info (actually a calendar pop-up allows me to make sure they do it in the correct format), into a textbox. When this page gets called up again, I want to prefill the box with the existing data, in case...
4
11964
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 14 (STDCOST). ---End Error Msg--- The STDCOST is set to decimal (28,14) and is a formatted in Access as a number, single with 14 decimal. I don't know why I would be getting a Type
4
1794
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 Type Mismatch Error. Any suggestions? Thanks. DS
1
3276
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. Source Error: Line 233: Line 234: rs =
19
21557
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 date is more than 10 months out. The query runs fine, but I when I put the criteria of >10 I get 'Data Type mismatch' error. The code below is the original query. I have since put all the datediff bit in code, with all variables declared as date,...
7
5359
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 that ARE breaking are no different then the ones that are NOT breaking... Any hely is appreciated... Mike CODE:
1
12186
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 = "F:\\Gokulraj\\doc2.doc"; object Target = "F:\\Gokulraj\\Temp\\gokul.pdf";
1
1754
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: _________________________________________________________________ Private Mint As Integer
1
1585
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: __________________________________________________ _______________Private Mint As Integer Dim date1 As Date Dim date2 As Date Dim myApplicationRecord As Application
0
8673
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9156
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9021
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7716
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4365
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3043
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2327
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1998
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.