Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Date$ and Time$
#1
Hello again... I have a new problem with qbasic...
I warn everyone that you may not understand me well because i'm argentinian and my english is a bit weak.

My problem is this:

I want to make three variables that contain the actual month, the actual time and the actual year.

I made something like this:

Code:
month$ =  LEFT$(DATE$,2)
year$ = RIGHT$(DATE$,4)
aux$ = LEFT$(DATE$, 5)
day$ = RIGHT$(aux$,2)

But when i try to make an operation with this variables i've got "Tipe missmatch" error, becouse QB thinks month$ is a string variable, but it has only numbers.

Is there any other way to get the actual time, year and day? Or is there any way to "convert" a string variable with only contains numbers?

Thanks a lot Wink
Reply
#2
Your english is fine. Smile

VAL will convert a string containing a number to a numeric value.

Code:
month = VAL(LEFT$(DATE$, 2))
year = VAL(RIGHT$(DATE$, 4))
aux$ = LEFT$(DATE$, 5)
day = VAL(RIGHT$(aux$, 2))
Reply
#3
i tryed your code and i didn't find a problem!
what exactly r u doing when you type run the code?

and u can use mid$ for day so you don't have to make a separate variable for to find day

Code:
month$ = LEFT$(DATE$, 2)
year$ = RIGHT$(DATE$, 4)
day$ = MID$(DATE$, 4, 2)
t is better to error on the side of caution
than the side of haste!!!
[Image: title3.jpg]
Reply
#4
The error is when i want to make something like:

Code:
a% = month$ - 4

I haven't tried any code yet but thank you both!

EDITED: It works perfectly... Thank you both!
Reply
#5
You would then need to do:

a% = VAL(month$) - 4

should work fine :-)
hen they say it can't be done, THAT's when they call me ;-).

[Image: kaffee.gif]
[Image: mystikshadows.png]

need hosting: http://www.jc-hosting.net
All about ASCII: http://www.ascii-world.com
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)