Results 1 to 9 of 9

Thread: Changing System Time

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2000
    Posts
    51

    Cool Changing System Time

    Is there a way to change the system time through VB. I found datetime.time control but I am at a loss on how to pass the new value to it.

    Could anyone help me???

    Thanks
    Everyone!!! Can I have your attention please?

    Sit back, Relax and watch the world unfold before your very eyes.

    Mystical isn't it, oh well I tried!!!

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    use the Time statement
    VB Code:
    1. Time = "12:00:00 PM"

    I think that works
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3

    Thread Starter
    Member
    Join Date
    Dec 2000
    Posts
    51

    Wink Thanks

    Thanks for the response!!

    I tried that but I couldn't get it to work. However, I did find a function called timevalue which turns a string value into a usable to value for the time command.
    Everyone!!! Can I have your attention please?

    Sit back, Relax and watch the world unfold before your very eyes.

    Mystical isn't it, oh well I tried!!!

  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    'you have to double click the clock icon in the systray for it to take effect
    Private Sub Form_Load()
    Dim MyTime
    MyTime = "11:00:00 PM"
    Time = MyTime
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  5. #5

    Thread Starter
    Member
    Join Date
    Dec 2000
    Posts
    51
    In the situation I need this in that would not be acceptable.

    Private Sub subSetTime()

    Dim tmpMin As String
    Dim tmpTime As Variant
    Dim tmpDelim As String
    Dim tmpHour As Integer

    If Len(cmbMins.Text) = 1 Then tmpMin = "0" & cmbMins.Text Else tmpMin = cmbMins.Text
    If Val(cmbHrs.Text) > 12 Then
    tmpHour = Val(cmbHrs.Text) - 12
    tmpDelim = " PM"
    Else
    tmpDelim = " AM"
    tmpHour = cmbHrs.Text
    End If

    tmpTime = TimeValue(Val(tmpHour) & ":" & Val(tmpMin) & ":00" & tmpDelim)

    Call SetTime(tmpTime)
    Everyone!!! Can I have your attention please?

    Sit back, Relax and watch the world unfold before your very eyes.

    Mystical isn't it, oh well I tried!!!

  6. #6
    Hyperactive Member mastermind94's Avatar
    Join Date
    Jun 2000
    Location
    Montréal, Canada
    Posts
    441
    I got a French computer... ;Does the time have to be entered as american time or International time (10:00 pm = 22:00)

  7. #7
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    'the system time is changed
    'but if you want to see the changed time in the systray
    'you have to double click the clock icon in the systray for it to take effect
    '
    'to test it run the code..your msgbox will give you the system time of 11 oclock pm
    
    Private Sub Command1_Click()
      MsgBox Now
    End Sub
    
    Private Sub Form_Load()
     Dim MyTime
     MyTime = "11:00:00 PM"
     Time = MyTime
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  8. #8
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Mastermind.

    just do a msgbox now in some event and see how your time is displayed and act accordingly.
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  9. #9

    Thread Starter
    Member
    Join Date
    Dec 2000
    Posts
    51
    Mastermind. . . . . .

    The time format is in international time 10:00pm = 22:00. If you look at the tmphours line I am converting the time from international to american. You will need to expirement with the code.

    The SetTime sub uses the DateTime.Time function to set the time for me. If you have any other questions regarding it let me know.
    Everyone!!! Can I have your attention please?

    Sit back, Relax and watch the world unfold before your very eyes.

    Mystical isn't it, oh well I tried!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width