473,657 Members | 2,405 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with Format Function

Hi All,
I'm using VB.Net 2005. I have for years used Format to format strings and
dates, etc...
Now when I try to use Format I get the following error?

"'Format' is a type and can not be used as an expression"

Can anyone help?

Thanks,
John.
Dec 3 '06 #1
8 5533
Thunder,

Probably as you show the code that you are using.
This kind of questions are popular.

Cor

"Thunder" <jr***@patmedia .netschreef in bericht
news:uY******** ******@TK2MSFTN GP04.phx.gbl...
Hi All,
I'm using VB.Net 2005. I have for years used Format to format strings and
dates, etc...
Now when I try to use Format I get the following error?

"'Format' is a type and can not be used as an expression"

Can anyone help?

Thanks,
John.

Dec 3 '06 #2
"Thunder" <jr***@patmedia .netschrieb:
I'm using VB.Net 2005. I have for years used Format to format strings and
dates, etc...
Now when I try to use Format I get the following error?

"'Format' is a type and can not be used as an expression"

Unfortunately 'Format' cannot be used to format strings any more.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Dec 3 '06 #3
Ok,
then what is to replace it?

I used to be able to write
dim STR as String = Format(Now(), "MM/dd/yyyy")

What would I write now?

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.atwrote in message
news:uA******** ******@TK2MSFTN GP02.phx.gbl...
"Thunder" <jr***@patmedia .netschrieb:
>I'm using VB.Net 2005. I have for years used Format to format strings
and dates, etc...
Now when I try to use Format I get the following error?

"'Format' is a type and can not be used as an expression"


Unfortunately 'Format' cannot be used to format strings any more.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Dec 4 '06 #4
Hmmm........

VS2005 - VB.NET

Add button to form

Add handler for Click event of button

Add the following to the event handler:

Dim STR As String = Format(Now(), "MM/dd/yyyy")
Console.Writeli ne(STR)

Press F5

Click the button and magically 12/04/2006 appears in the output window.

How can that happen if 'Format' cannot be used to format strings any more?.
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.atwrote in message
news:uA******** ******@TK2MSFTN GP02.phx.gbl...
"Thunder" <jr***@patmedia .netschrieb:
>I'm using VB.Net 2005. I have for years used Format to format strings
and dates, etc...
Now when I try to use Format I get the following error?

"'Format' is a type and can not be used as an expression"


Unfortunately 'Format' cannot be used to format strings any more.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Dec 4 '06 #5
Thunder wrote:
Ok,
then what is to replace it?

I used to be able to write
dim STR as String = Format(Now(), "MM/dd/yyyy")

What would I write now?

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.atwrote in message
news:uA******** ******@TK2MSFTN GP02.phx.gbl...
>"Thunder" <jr***@patmedia .netschrieb:
>>I'm using VB.Net 2005. I have for years used Format to format strings
and dates, etc...
Now when I try to use Format I get the following error?

"'Format' is a type and can not be used as an expression"

Unfortunatel y 'Format' cannot be used to format strings any more.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

I don't know why you feel you can't use Format (or why you're being told
you can't) but the following works perfectly for me! -

Dim sString As String = Format(Now, "MM/dd/yyyy")
Debug.Print(sSt ring)

Maybe post the code you're having problems with so we can see where you
might be going wrong.

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
Dec 4 '06 #6
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.atwrote in message
news:uA******** ******@TK2MSFTN GP02.phx.gbl...
>"Thunder" <jr***@patmedia .netschrieb:
>>I'm using VB.Net 2005. I have for years used Format to format
strings and dates, etc...
Now when I try to use Format I get the following error?

"'Format' is a type and can not be used as an expression"


Unfortunatel y 'Format' cannot be used to format strings any more.
Thunder wrote:
Ok,
then what is to replace it?

I used to be able to write
dim STR as String = Format(Now(), "MM/dd/yyyy")

What would I write now?
[Please put your reply *after* the text you're quoting.]

DateTime.Today. ToString("yyyy-MM-dd")

Or it may be that you don't have "Imports System.String" to tell it which
bit of namespace to look in for the Format method.

Always put "Option Strict On" at the top so it knows to tell you when it's
unsure of something.

Andrew
Dec 4 '06 #7
Thanks,
That is what I was looking for.
The DateTime.Parse( <datevalue>).To string("MM/dd/yyyy")
returns the correct value.

I have used format I think since version 4 of VB, I just recently switched
from VS.NET 2003 to 2005 and ran into this situation. So if someone is able
to get Format working in VS.NET 2005, I don't know what my problem is?

Thanks all for you help.

"Andrew Morton" <ak*@in-press.co.uk.inv alidwrote in message
news:uU******** ******@TK2MSFTN GP06.phx.gbl...
>"Herfried K. Wagner [MVP]" <hi************ ***@gmx.atwrote in message
news:uA******* *******@TK2MSFT NGP02.phx.gbl.. .
>>"Thunder" <jr***@patmedia .netschrieb:
I'm using VB.Net 2005. I have for years used Format to format
strings and dates, etc...
Now when I try to use Format I get the following error?

"'Format' is a type and can not be used as an expression"
Unfortunate ly 'Format' cannot be used to format strings any more.

Thunder wrote:
>Ok,
then what is to replace it?

I used to be able to write
dim STR as String = Format(Now(), "MM/dd/yyyy")

What would I write now?

[Please put your reply *after* the text you're quoting.]

DateTime.Today. ToString("yyyy-MM-dd")

Or it may be that you don't have "Imports System.String" to tell it which
bit of namespace to look in for the Format method.

Always put "Option Strict On" at the top so it knows to tell you when it's
unsure of something.

Andrew

Dec 4 '06 #8
Stephany Young wrote:
Hmmm........

VS2005 - VB.NET

Add button to form

Add handler for Click event of button

Add the following to the event handler:

Dim STR As String = Format(Now(), "MM/dd/yyyy")
Console.Writeli ne(STR)

Press F5

Click the button and magically 12/04/2006 appears in the output window.

How can that happen if 'Format' cannot be used to format strings any more?.
In addition, you can use String.Format for complex formatting:

Dim str As String = String.Format(" The current date is {0:MM/dd/yyyy}",
DateTime.Now)
Console.WriteLi ne(str)

Chris

Dec 4 '06 #9

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

Similar topics

2
3587
by: Anthony | last post by:
I am trying to get a users DN by translating the LOGON_USER NT4 format variable. I am ONLY using windows authentication for security settings: This is a Windows 2000 IIS 5 Server. Here is the .asp that I've stripped down.. feel free to paste the code for your own testing.. it works: ----------------- begin paste-- ----------- <% ' logon_user will be in DOMAIN\LANID format (NT4 Format) logonuser = Request.ServerVariables("LOGON_USER")
2
1415
by: Brad Pepers | last post by:
For the life of me I can't see why this code won't compile even though its very simple. Any hints? I get errors in NumberValcon::format(int) when it tries to call format() but why doesn't it use the format() in the parent Valcon class? Also there is an error in the main() code when trying to use MoneyValcon::format(int) but why doesn't main use the one from NumberValcon which is the parent of MoneyValcon? This is on all SuSE 9.2 using...
0
3931
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen. It is almost like it is trying to implement it's own COM interfaces... below is the header, and a link to the dll+code: Zip file with header, example, and DLL:...
12
29445
by: Assimalyst | last post by:
Hi, I have a working script that converts a dd/mm/yyyy text box date entry to yyyy/mm/dd and compares it to the current date, giving an error through an asp.net custom validator, it is as follows: function doDateCheckNow(source, args) { var oDate = document.getElementById(source.controltovalidate); // dd/mm/yyyy
0
3916
by: Suresh | last post by:
Hi Guys I have Db2 server installed on remote server. i am connecting to that remote server by using VPN. I want to connect that remote DB2 server instance using my local machine DB2 development client. Bur Its gives me following error message. I searched lots of things on net and tried on remote server but i didnt got suceess. Can any one tell me how to set TCP\IP connection protocol on server for particular instance. Becuase I think
5
23999
by: Suresh | last post by:
Hi Guys I have Db2 server installed on remote server. i am connecting to that remote server by using VPN. I want to connect that remote DB2 server instance using my local machine DB2 development client. Bur Its gives me following error message. I searched lots of things on net and tried on remote server but i didnt got suceess. Can any one tell me how to set TCP\IP
7
4811
by: Kamal | last post by:
Hello all, I have a very simple html table with collapsible rows and sorting capabilities. The collapsible row is hidden with css rule (display:none). When one clicks in the left of the expandable row, the hidden row is made visible with css. The problem is when i sort the rows, the hidden rows get sorted as well which i don't want and want to be moved (while sorting) relative to their parent rows. The following is my complete html code...
2
3147
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button then the calender gone actually i want if i click outside off the calender then it should me removed ..How kan i do this ... Pls inform me as early as possible .. I am waiting for ur quick replay ...Here i attached the source code .... <!DOCTYPE...
1
1351
by: swathichavalla | last post by:
Problem description: Clients working with an apple computer with the safari browser are experiencing problems with brokerage orders. When the client wants to enter a stock order, the order entry screen displays 31-12-2005 as date. When the client presses the OK button, it states that the entered date is wrong. When the client changes the date to 31-12-2006, the application says the date is wrong. If he uses the firefox browser he has no...
11
5001
by: jessy | last post by:
Hi, I have a problem with my DateTimePicker javascript code which i downloaded , the problem is when i pick the date and the date appears in my Text Field and i click Submit the date which i picked is not sent to the DB and instead the default value of the text field which is 00-00-0000 is Sent so what i need is to make the value i picked replace the value of the Text Field and i cant seem to get the Js code which i downloaded . i'm...
0
8324
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8740
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...
1
8516
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8617
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7353
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
6176
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
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1733
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.