1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

How Do I?... In Visual Basic 6

Discussion in 'Software Development' started by Damonc, Oct 24, 2002.

Thread Status:
Not open for further replies.
Advertisement
  1. Damonc

    Damonc Thread Starter

    Joined:
    May 9, 2001
    Messages:
    655
    First Name:
    Damon
    I just need to know two things, how to get the current date, the second is the program that Im writing is linked to a Microsoft Access Database, I need a way to print the contents of the database through the program, anyone happen to know any code for that?
     
  2. deuce868

    deuce868

    Joined:
    Nov 2, 2000
    Messages:
    637
  3. AbvAvgUser

    AbvAvgUser

    Joined:
    Oct 3, 2002
    Messages:
    2,281
    The first part of your query is quite simple. There are inbuilt VB functions for that.

    Time() gives the current time
    Date() gives the current date
    Now() gives both at the same time

    For the second part, I will try to find out and come back. Till than hang on.

    And in the mean time of you find the solutions, please post it so that many of us can benefit from your knowledge :)
     
  4. Damonc

    Damonc Thread Starter

    Joined:
    May 9, 2001
    Messages:
    655
    First Name:
    Damon
    Thanks for the first part!
     
  5. Damonc

    Damonc Thread Starter

    Joined:
    May 9, 2001
    Messages:
    655
    First Name:
    Damon
    OK... heres a Dumb question, now that I have the code for the date, how can I get it to display in a text box?

    On the form, i've put a text box to try to get the date to be displayed in there... the textbox is still called text1, I've put the code on the form load section so I've got this as my code"

    Private sub form_load ()
    date() = text1
    end sub

    but its having a type mismatch.... How do I do this correctly?
     
  6. fpat

    fpat

    Joined:
    Nov 4, 2000
    Messages:
    139
    Make it:
    text1.text=date
     
  7. Damonc

    Damonc Thread Starter

    Joined:
    May 9, 2001
    Messages:
    655
    First Name:
    Damon
    Thanks!
     
  8. Damonc

    Damonc Thread Starter

    Joined:
    May 9, 2001
    Messages:
    655
    First Name:
    Damon
    OK, this turning out a lot harder than what I thought it would... Yup, you guessed it I need more help!.

    everything that I have been helped with so far has worked without a problem, but now I'm trying to impement something and I thought it would be a lot easier that what it has turned out to be.

    I've got my date loading into the form, now what I want to do is compare that date to a date that is manually entered into another text box, and if the date manually entered has past the current date (in otherwords making it overdue), then display a message box.. this is what I tried to do:

    if x > y then
    msgbox "message"
    else
    (I don't need it to do anything as an else)
    end if


    x = current date
    y = the manaully entered date.
     
  9. AbvAvgUser

    AbvAvgUser

    Joined:
    Oct 3, 2002
    Messages:
    2,281
    You are facing these problems in comparing x & y values because you have converted dates to text. If you let them remain as dates, you can directly compare them like any other data values.

    But why are you struggling so much with dates and text. For dates, you can directly use DTPicker. You can place it directly on your forms wherever you need to display or get text.

    If it is not there in Tool Box, you need to add component for it to appear. Go to Project > Components and add the component that you need. This one must be in Microsoft Windows Common Controls 6.0 or something like that. Or the simpler alternative is to start a new project as VB Enterprise Edition Compnents instead of as Standard EXE.
     
  10. Damonc

    Damonc Thread Starter

    Joined:
    May 9, 2001
    Messages:
    655
    First Name:
    Damon
    OK... thanks....
     
  11. Damonc

    Damonc Thread Starter

    Joined:
    May 9, 2001
    Messages:
    655
    First Name:
    Damon
    In as much detail as I can here is what I'm doing, I'm making a To-Do list for a course that I am doing in basic programming, this assignment was given out and everyone is struggling with parts of it, the teacher doesn't care how we get the code but as long as we make the program our selfs.
    There is certain crietiera that has to be met, and the one that I'm having trouble with is getting the program to remind the user of overdue tasks. The program its self is linked to an Access database (all execpt for the Priority drop-down box which keeps telling me that it cannot be bound to the database... so if you can explain that one too it would be good)
    I have the dates that I have put the coloured circles around (see screenshot) they are both formatted to date, in both the program and the database, I'm using the following code when the form loads to get the program to display a message box if the duedate has past.

    if entereddate > duedate then
    msgbox "your task is overdue"
    else
    end if

    Now because I have both fields formatted to the date I thought that it would work, but I still doesn't. I tried using the DTPicker, but once again I get the error that it cannot be binded to the database (which I need to do, so that when the program is closed and then re-opened then information is still there)

    Now I hope that my big long discription has helped, and that someone can point me in the right direction.
     

    Attached Files:

  12. AbvAvgUser

    AbvAvgUser

    Joined:
    Oct 3, 2002
    Messages:
    2,281
    From your screen shot, I can see that you are still using the textboxes instead of a DTPicker. Does the command button "Calendar" open a DTPicker? Formating a textbox to date is not the solution. The right and easiest thing is to use a DTPicker. Check out its properties. .value is what is useful to you alongwith .mindate and .maxdate.

    Are you using Bound Controls? I think that limits the functionality a great deal. See if you can make this using unbound controls. That seems to be the biggest problem here. Once you stop using bound controls, all this small problems will be solved. Of course, you will have to do some more coding for it. But its worth the effort. I have never used bound controls becuase they have so many limitations and I think are rightly called "bound". I don't think I can give you much hints because I never used them nor ever intend to do so. If you do away with bound controls and want any help, I can try.
     
  13. Damonc

    Damonc Thread Starter

    Joined:
    May 9, 2001
    Messages:
    655
    First Name:
    Damon
    Sorry I should have said that I have gotten the problem solved... I used the "datevalue" command.
     
  14. AbvAvgUser

    AbvAvgUser

    Joined:
    Oct 3, 2002
    Messages:
    2,281
    Good you figured out what the problem was. It is more satisfying to figure out the problem on our own :)

    As long as this is only an educational attempt, I guess it is alright to use something as naive as bound controls. But I strongly suggest that you learn how to use unbound controls and also how to use ADO (ActiveX Data Objects).

    I have been using DAO and unbound controls since quite some time. I am quite comfortable with it but then I know that it is slowly fading out and ADO is the thing to learn. I am trying to learn that and hope to get hang of it soon. Hope you start using unbound controls because eventually if you ever think of making a proper working software using databases, you will have to use that.

    All the best.
     
  15. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/100994

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice