在日期和数组中存储日期 [英] Storing Dates inside and array

查看:78
本文介绍了在日期和数组中存储日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码,但收到错误:


Dim installment = 1

Dim beginDate =" 1/1 / 03"

Dim endDate =" 1/1 / 08"

Dim dates(5)As Array

虽然分期付款< = 5

endDate = DateAdd(DateInterval.Year,1,beginDate)

dates.SetValue(couponEndDate,分期付款)

分期付款=分期付款+ 1

beginDate = endDate

结束时


我甚至尝试将日期值转换为字符串,但仍然收到

对象不能存储在这种类型的数组中。


TIA,


Steve Wofford
www.IntraRELY.com

解决方案

你好史蒂夫,


第一个问题,你正在使用什么vb.net版本。

我的第一个问题是它没有Vs.net是什么看来,但是看到了你的链接

你支持使用Visual Studio可能是正常的。


Dim installment = 1不是很好的代码,可能是

Dim installment as integer = 1
Dim beginDate =" 1/1 / 03"可以是

Dim beginDate as string =" 1/1 / 03"但你可能想把它作为约会。


代码中没有一个错误但可能是10个。


我的建议,从你的程序顶部开始

选项明确

选项严格


比你看到很多这个错误是直接的。


我希望这有点帮助吗?


Cor

这是我的代码,但得到错误:

Dim installment = 1
Dim beginDate =" 1/1 / 03"
Dim endDate =" 1 / 1/08"
Dim dates(5)As Array
虽然分期付款< = 5
endDate = DateAdd(DateInterval.Year,1,beginDate)
dates.SetValue(couponEndDate) ,分期付款)
installment = installment + 1
beginDate = endDate
结束时我甚至试图将日期值转换为字符串,但仍然收到了
&quo t;对象不能存储在这种类型的数组中。

TIA,

史蒂夫沃福德
www.IntraRELY.com



尝试

生病修改你的代码

Dim installment = 1
Dim beginDate as new datetime(cdate(" 1/1 / 03" ;))
昏暗的结束日期作为新的日期时间(cdate(1/108))
昏暗的日期(5)作为日期时间
不确定你是否想要在这里做分期付款< = 5
endDate = DateAdd(DateInterval.Year,1,beginDate)
dates.SetValue(couponEndDate,分期付款)
installment = installment + 1
beginDate = endDate <结束时

试试这个

for i as integer = 1到5

dates(i)= dateadd((DateInterval.Year ,我,开始日期)

下一页

我甚至试图将日期值转换为字符串,但仍然收到
对象不能存储在这种类型的数组中。
TIA,

Steve Wofford
www.IntraRELY.com



*" IntraRELY" <在******* @ yahoo.com> scripsit:

这是我的代码,但得到错误:

Dim installment = 1
Dim beginDate =" 1/1 / 03"
Dim endDate =" 1/1 / 08"


以特定类型声明上述变量,''分期''为

''整数'',其他变量为''日期'' 。使用#1/1 / 08#而不是

"" 1/1 / 08""。

Dim dates(5)As Array


为什么不''作为日期''?

虽然分期付款< = 5
endDate = DateAdd(DateInterval.Year,1,beginDate)
dates.SetValue(couponEndDate,分期付款) )
installment = installment + 1
beginDate = endDate
结束时我甚至试图将日期值转换为字符串,但仍然收到
对象不能存储在这种类型的数组中。




你确定你知道你想做什么吗?


-

Herfried K. Wagner [MVP]

< http://www.mvps.org/dotnet>


Here is my code, but get errors:

Dim installment = 1
Dim beginDate = "1/1/03"
Dim endDate = "1/1/08"
Dim dates(5) As Array
While installment <= 5
endDate = DateAdd(DateInterval.Year, 1, beginDate)
dates.SetValue(couponEndDate, installment)
installment = installment + 1
beginDate = endDate
End While

I even tried to conver the date value to a string, but still recieved
"Object cannot be stored in an array of this type."

TIA,

Steve Wofford
www.IntraRELY.com

解决方案

Hi Steve,

First question, what vb.net version are you using.
My first thougth was that it was without Vs.net what it seems, but seeing
the link you supported you probably are normal using Visual Studio.

Dim installment = 1 is not good code that would probably be
Dim installment as integer = 1
Dim beginDate = "1/1/03" can be
Dim beginDate as string = "1/1/03" but you probably want to do it as a date.

There is not one error in the code but probably 10.

My advice, start with to put in the top of your program
option explicit on
option strict on

Than you sees a lot of this errors direct.

I hope this helps a little bit?

Cor

Here is my code, but get errors:

Dim installment = 1
Dim beginDate = "1/1/03"
Dim endDate = "1/1/08"
Dim dates(5) As Array
While installment <= 5
endDate = DateAdd(DateInterval.Year, 1, beginDate)
dates.SetValue(couponEndDate, installment)
installment = installment + 1
beginDate = endDate
End While

I even tried to conver the date value to a string, but still recieved
"Object cannot be stored in an array of this type."

TIA,

Steve Wofford
www.IntraRELY.com



some things to try
ill modify your code a bit

Dim installment = 1
Dim beginDate as new datetime(cdate("1/1/03"))
Dim endDate as new datetime(cdate("1/1/08"))
Dim dates(5) As datetime not sure w you are trying to do here While installment <= 5
endDate = DateAdd(DateInterval.Year, 1, beginDate)
dates.SetValue(couponEndDate, installment)
installment = installment + 1
beginDate = endDate
End While
try this
for i as integer = 1 to 5
dates(i) = dateadd((DateInterval.Year, i, beginDate)
next
I even tried to conver the date value to a string, but still recieved
"Object cannot be stored in an array of this type."

TIA,

Steve Wofford
www.IntraRELY.com



* "IntraRELY" <In*******@yahoo.com> scripsit:

Here is my code, but get errors:

Dim installment = 1
Dim beginDate = "1/1/03"
Dim endDate = "1/1/08"
Declare the variables above in a specific type, ''installment'' as
''Integer'', the other variables as ''Date''. Use "#1/1/08#" instead of
""1/1/08"".
Dim dates(5) As Array
Why not ''As Date''?
While installment <= 5
endDate = DateAdd(DateInterval.Year, 1, beginDate)
dates.SetValue(couponEndDate, installment)
installment = installment + 1
beginDate = endDate
End While

I even tried to conver the date value to a string, but still recieved
"Object cannot be stored in an array of this type."



Are you sure you know what you want to do?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>


这篇关于在日期和数组中存储日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆