Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
2.60/5 (5 votes)
See more:
Hi, everyone. I'm adding new stuff to a really really old (and vb6) program on Windows 7.
The program uses the DateTime member Second to get the current time's seconds.

My problem is that I have to comment out Second (Minute, Hour work fine) in order to make an executable, or compile the source. If I don't an index error pops up. Why Minute and Hour work fine, but not Second, is beyond me...

If anyone knows how I can compile/make exe file without the error poppling up (and on a Windows 7 machine), please let me know.

Thanks in advance!

[EDIT]The section below was moved from comment - LOSMAC[/EDIT]

Ok, I don't know the solution to my problem, but I found another way to do the same thing that doesn't make an errors on Win7.. I would really like to change the code back to its original state if possible, so I'm still looking for solutions.

VB
Dim sec As Byte
Dim min As Byte
Dim strSec As String
'** Minute works OK
min = Minute(Time)
'** Second is No good (So I deleted it)
'** sec = Second(Time)
'** The following code doesn't make any errors, so I'm using it...
strSec = Format(Time, "s") sec = Val(strSec)
Posted
Updated 18-Apr-12 11:36am
v2
Comments
Chandrasekharan P 16-Apr-12 14:04pm    
What is the error that you are getting?
mgw2sei 16-Apr-12 22:56pm    
The error is in Japanese as my both my OS (Windows 7 Pro) and VB6 are the Japanese versions, but here goes:


コンパイルエラー:
配列がありません。

If I were to put that into English, it would be like this:

Compile Error:
No Array.


*The reason I'm asking this question in an English speaking (rather than Japanese) community is because I'm a native English speaker.


Anyway, have you experienced anything similar?
Maciej Los 17-Apr-12 12:58pm    
Show us a piece of code where you get an error.
mgw2sei 17-Apr-12 20:28pm    
Ok, I don't know the solution to my problem, but I found another way to do the same thing that doesn't make an errors on Win7..
I would really like to change the code back to its original state if possible, so I'm still looking for solutions.

Dim sec As Byte
Dim min As Byte
Dim strSec As String

'** Minute works OK
min = Minute(Time)
'** Second is No good (So I deleted it)
'** sec = Second(Time)
'** The following code doesn't make any errors, so I'm using it...
strSec = Format(Time, "s")
sec = Val(strSec)
Maciej Los 18-Apr-12 17:41pm    
Try to change the type of variable: from Byte to Integer. See my solution.

1 solution

Please, read more about DateTime.Second[^] Property.
 
Share this answer
 
Comments
mgw2sei 20-Apr-12 1:50am    
Thanks, I checked out the link.
They use an Integer where as the source I'm working on uses Byte.
And I guess Windows 7 just wasn't having it.

Anyway, I changed it, and the program works fine!
Thanks, and sorry for the late reply.
Maciej Los 20-Apr-12 11:15am    
No problem. If my answer was helpful, please rate it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900