"格式"题 [英] "Format" Question
问题描述
首先,我正在使用vb2005。我有一个从条形码阅读器读取到TextBox的字符串。该字符串长度为6个字符,
表示日期(mmddyy)。我希望以mm / dd / yy的日期格式将其显示给用户。例如,条形码包含
" 112303"并且我想格式化它以显示11/23/03
如果我使用microsoft.visualbasic.strings.format,格式字符串为## /# #/ ##"或00/00/00或我在
TextBox中获取格式字符串。如果我使用microsoft.visualbasic.compatibility.vb6.format它可以正常工作。
我在这里缺少什么?我宁愿不使用VB6兼容性。
TIA,
-
Al Reid
First, I''m using vb2005. I have a string that is read from a barcode reader into a TextBox. The string is 6 characters long and
represents a date (mmddyy). I want to display it to the user in a date format of "mm/dd/yy" For example the barcode contains
"112303" and I want to format it to display "11/23/03"
If I use the microsoft.visualbasic.strings.format with a format string of "##/##/##" or "00/00/00" I get the format string in the
TextBox. If I use the microsoft.visualbasic.compatibility.vb6.format it works as I expect.
What Am I missing here? I would prefer not to use the VB6 compatibility.
TIA,
--
Al Reid
推荐答案
" Al Reid" < AR ***** @ reidDASHhome.com> schrieb
"Al Reid" <ar*****@reidDASHhome.com> schrieb
首先,我正在使用vb2005。我有一个从条形码阅读器读取到TextBox的字符串。该字符串长度为6个字符,
表示日期(mmddyy)。我希望以mm / dd / yy的日期格式将其显示给用户。例如条形码包含112303
我想格式化它以显示11/23/03
如果我使用microsoft.visualbasic.strings.format和格式
字符串## / ## / ##或00/00/00或我在
TextBox中获得了格式字符串。如果我使用
microsoft.visualbasic.compatibility.vb6.format它可以正常工作。
我在这里缺少什么?我宁愿不使用VB6
兼容性。
First, I''m using vb2005. I have a string that is read from a
barcode reader into a TextBox. The string is 6 characters long and
represents a date (mmddyy). I want to display it to the user in a
date format of "mm/dd/yy" For example the barcode contains "112303"
and I want to format it to display "11/23/03"
If I use the microsoft.visualbasic.strings.format with a format
string of "##/##/##" or "00/00/00" I get the format string in the
TextBox. If I use the
microsoft.visualbasic.compatibility.vb6.format it works as I expect.
What Am I missing here? I would prefer not to use the VB6
compatibility.
首先将它转换为Date变量。在内部始终使用它。要将
转换为字符串,请使用它的ToString方法。
dim s as string =" 112303"
d d作为日期
d = date.parseexact(s,MMddyy,什么都没有)
textbox1.text = d.tostring(" MM \ / dd \ / yy")
Armin
Convert it to a Date variable first. Internally always work with it. To
convert to a string, use it''s ToString method.
dim s as string = "112303"
dim d as date
d = date.parseexact(s, "MMddyy", nothing)
textbox1.text = d.tostring("MM\/dd\/yy")
Armin
" Armin Zingler" < AZ ******* @ freenet.de>在消息新闻中写道:ez ************** @ TK2MSFTNGP10.phx.gbl ...
"Armin Zingler" <az*******@freenet.de> wrote in message news:ez**************@TK2MSFTNGP10.phx.gbl...
" Al Reid" < AR ***** @ reidDASHhome.com> schrieb
"Al Reid" <ar*****@reidDASHhome.com> schrieb
首先,我正在使用vb2005。我有一个从条形码阅读器读取到TextBox的字符串。该字符串长度为6个字符,
表示日期(mmddyy)。我希望以mm / dd / yy的日期格式将其显示给用户。例如条形码包含112303
我想格式化它以显示11/23/03
如果我使用microsoft.visualbasic.strings.format和格式
字符串## / ## / ##或00/00/00或我在
TextBox中获得了格式字符串。如果我使用
microsoft.visualbasic.compatibility.vb6.format它可以正常工作。
我在这里缺少什么?我宁愿不使用VB6
兼容性。
First, I''m using vb2005. I have a string that is read from a
barcode reader into a TextBox. The string is 6 characters long and
represents a date (mmddyy). I want to display it to the user in a
date format of "mm/dd/yy" For example the barcode contains "112303"
and I want to format it to display "11/23/03"
If I use the microsoft.visualbasic.strings.format with a format
string of "##/##/##" or "00/00/00" I get the format string in the
TextBox. If I use the
microsoft.visualbasic.compatibility.vb6.format it works as I expect.
What Am I missing here? I would prefer not to use the VB6
compatibility.
首先将它转换为Date变量。在内部始终使用它。要转换为字符串,请使用它的ToString方法。
dim s as string =" 112303"
dim d as date
> d = date.parseexact(s,MMddyy,没什么)
textbox1.text = d.tostring(" MM \ / dd \ / yy")
Armin
Convert it to a Date variable first. Internally always work with it. To
convert to a string, use it''s ToString method.
dim s as string = "112303"
dim d as date
d = date.parseexact(s, "MMddyy", nothing)
textbox1.text = d.tostring("MM\/dd\/yy")
Armin
谢谢,但这并没有回答有关Format函数的两个变体的问题。你知道正确的格式字符串
使Strings.Format功能正常工作吗?
-
Al Reid
Thanks, but that doesn''t answer the question about the two variations of the Format function. Do you know the correct format string
required to make the Strings.Format function work properly?
--
Al Reid
" Al Reid" < AR ***** @ reidDASHhome.com> schrieb
"Al Reid" <ar*****@reidDASHhome.com> schrieb
谢谢,但这并没有回答有关Format函数的两个变种的问题。你知道使Strings.Format函数正常工作所需的格式正确吗?
Thanks, but that doesn''t answer the question about the two
variations of the Format function. Do you know the correct format
string required to make the Strings.Format function work properly?
不是。它们只是不同:
< a rel =nofollowhref =http://msdn.microsoft.com/library/en-us/vbcn7/html/vaconFormatChangesInVBNET.asp\"target =_ blank> http://msdn.microsoft.com/library / en...gesInVBNET.asp
Armin
No. They are just different:
http://msdn.microsoft.com/library/en...gesInVBNET.asp
Armin
这篇关于"格式"题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!