Visual Basic 2008 question

Discussion in 'Software' started by Dark_Horse, Aug 12, 2008.

  1. Dark_Horse

    Dark_Horse Private E-2

    I'm writing a small game....but I want a button (named next day) to change the date of the calender that I added to next day on the calender.....help would be much liked
     
  2. Dark_Horse

    Dark_Horse Private E-2

    Sorry refrase........I want the button to change the calender day to the next day....I have tried a few commands but can't seem to get it to work...I tried

    monthcalender1.setdate() now inside the "()" I don't know what to do....should I make a veriable or something?
     
  3. PC-XT

    PC-XT Master Sergeant

    I'm not too familiar with this, but I would think it would be something like
    Code:
    monthcalender1.setdate(monthcalender1.getdate()+1000*60*60*24)
    assuming that is setdate(milliseconds). If it is actually text or something else, it would need to be adjusted. Most clocks have a set function for milliseconds or seconds. Calendars may go by days, in which case the code would simply be
    Code:
    monthcalender1.setdate(monthcalender1.getdate()+1)
    If this causes a type error, it might be easier to look for another function.
     
  4. Dark_Horse

    Dark_Horse Private E-2

    Thanx for the help PC-XT....I'm progressing (I think), your code didn't work as .gedate can't form part of the statment...I'm trying this now

    Code:
     Dim datechange As DateTime = 
    
            MonthCalendar1.SetDate(datechange)
    
    but when ever I want to change the datechange value I get a error that its not a double

    Code:
    Dim datechange As DateTime = Date.Parse("11/08/2008" + 1)
    
            MonthCalendar1.SetDate(datechange)
     
  5. Dark_Horse

    Dark_Horse Private E-2

    If I can't get this code to work.....then can someone maybe suggest a different way of getting a calendar up and being able to change the date?
     
  6. Dark_Horse

    Dark_Horse Private E-2

    I've figured out how to change the date:
    Code:
    Dim myDT As New Date (2008, 8, 17)
    
    myDT = myDT.AddDays(1)
    
    MonthCalendar1.setDate(myDT)
    But now the second problem it will only change it once and if I run a loop it only changes the date by 2 and doesn't change again....please I need to figure this out
     
  7. asplode

    asplode Private E-2

    I imagine it's not incrementing because you have the start date hardcoded in. I'd use a variable to hold the start date data and run the variable through the loop...
     
  8. PC-XT

    PC-XT Master Sergeant

    Maybe something like:
    Code:
    Dim myDT As DateTime
    MonthCalendar1.setDate(New Date(2008, 8, 17))
    do
    ...
    myDT = MonthCalendar1.getDate()
    MonthCalendar1.setDate(myDT.AddDays(1))
    loop
    ? That uses getDate() again. Alternatively, maybe:
    Code:
    Dim myDT As DateTime
    myDT=New Date(2008, 8, 17)
    do
    MonthCalendar1.setDate(myDT)
    ...
    myDT=myDT.AddDays(1)
    loop
    ? Also, maybe:
    Code:
    Dim myDT As New Date(2008, 8, 17)
    for i=0 to x
    MonthCalendar1.setDate(myDT.AddDays(i))
    ...
    next
    ?
    I hope one of these works.

    BTW, sorry I didn't see your posts until now. I had to work hard all last week.
     
  9. Dark_Horse

    Dark_Horse Private E-2

    Thanx for the help once again. The only problem is it keeps looping non stop, but when you stop it and click the bottun again it doesn't change the date
     
  10. PC-XT

    PC-XT Master Sergeant

    I meant the elipses (...) to be the code that is executed between the days. That is, do (or for) is where the main program loop begins, and loop/next is where it ends. If your program doesn't have a main loop, (where the button continues the loop,) but rather, the button just increments the date, the setup code would be the part before the do or for, and the button code would be the part just before the loop or next. An exception is in the second code, which includes setup/increment code at the loop start, which should be included at the end of the setup and the end of the increment, like:
    Code:
    'setup code
    Dim myDT As DateTime
    myDT=New Date(2008, 8, 17)
    MonthCalendar1.setDate(myDT)
    
    'place the following in button code
    myDT=myDT.AddDays(1)
    MonthCalendar1.setDate(myDT)
    For the others, it's basically just put the stuff between do/loop or for/next in the button function. If you run the increment in the button function directly, you don't need the loop. You still need the stuff at the beginning, before the loop, to be at the beginning of the main code (not the button function) to set up.

    The for loop one would need to have i=i+1 at the beginning of the button function also.
    Code:
    i=i+1
    MonthCalendar1.setDate(myDT.AddDays(i))
    (You may want to use a variable other than i, such as day, which is more descriptive.)

    I had the loops in there for the progression loop style of game making, where the next day button sets a variable or something to continue the loop (going to the next day), and the game ends by exiting the loop. The main part of the game is in the loop where the ... is. I find this way is often less of a difficulty to implement, although it is fine to just use the button to directly increment the calendar also. The main problem there is making sure the function has access to the necessary variables/objects. [You may need to alter the dim statement to make sure the function has access.]
     
    Last edited: Aug 20, 2008
  11. Dark_Horse

    Dark_Horse Private E-2

    Thank You PC-XT....you've been a great help. It's working now.....thanx agai for trying to educate a bafoon like me :p
     
  12. PC-XT

    PC-XT Master Sergeant

    lol. Glad it's working. Also glad my posts helped, even though they were a bit confusing.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds