Results 1 to 7 of 7

Thread: [RESOLVED] Mod Help

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    60

    Resolved [RESOLVED] Mod Help

    Hi,
    I'm still fairly new to vb so I'm a bit of a noob!


    I'm making a something that will display the number of months,weeks and remainding days if a user inputs a certain amount of days.
    e.g. user input: 45 Days

    Displays: 1 Month, 2 weeks, 1 day.

    I am using MOD for this but i'm a bit stuck for what code.
    So far:

    input MOD 7 = lbldays

    And yeah. SO how do i get it to display x no. of week once it gets to 7 days.
    I have the days going fine... I think. Because every 7 clicks of a scroll bar it resets.
    Thanks

  2. #2
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: Mod Help

    what abt this?
    Code:
    Private Sub Command1_Click()
    Dim m As Integer, w As Integer, d As Integer
    Dim days As Integer
    days = 45
    m = Int(days / 30)
    w = Int((days - (m * 30)) / 7)
    d = days - (m * 30) - (w * 7)
    MsgBox m & "," & w & "," & d
    End Sub
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    60

    Re: Mod Help

    Thanks seenu but I NEED TO USE MOD-Its for a school project!

    AND
    I want it to be able to use for any day amount put in. Not just 45-I was just using as an example.
    So a user selects a number of days on a scroll bar and then it displays it in week,days etc.

  4. #4
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: Mod Help

    it's not only for 45 days, anyway try this with a label and scroll bar
    Code:
    Private Sub Form_Load()
    With HScroll1
        .Min = 1
        .Max = 100
    End With
    End Sub
    
    Private Sub HScroll1_Change()
    Dim m As Integer, w As Integer, d As Integer, Temp As Integer
    Dim days As Integer
    days = HScroll1.Value
    m = Int(days / 30)
    Temp = days Mod 30 'temp = balance days
    w = Int(Temp / 7)
    Temp = Temp Mod 7 'temp = balance days
    d = Temp
    
    Label1.Caption = "Month = " & m & " Week = " & w & " Day = " & d
    
    End Sub
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


  5. #5
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Mod Help

    Quote Originally Posted by homer5677 View Post
    Hi,
    I'm still fairly new to vb so I'm a bit of a noob!


    I'm making a something that will display the number of months,weeks and remainding days if a user inputs a certain amount of days.
    e.g. user input: 45 Days

    Displays: 1 Month, 2 weeks, 1 day.

    I am using MOD for this but i'm a bit stuck for what code.
    So far:

    input MOD 7 = lbldays

    And yeah. SO how do i get it to display x no. of week once it gets to 7 days.
    I have the days going fine... I think. Because every 7 clicks of a scroll bar it resets.
    Thanks
    What does 'Because every 7 clicks of a scroll bar it resets" mean?

    BTW you might want to mention to your teacher that the answer is more reasonably 1 Month, 2 weeks because more moths have 31 days, than 30 unless he/she specifically said to assume that a month has 30 days.

  6. #6
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: Mod Help

    Quote Originally Posted by homer5677 View Post
    Thanks seenu but I NEED TO USE MOD-Its for a school project!

    AND
    I want it to be able to use for any day amount put in. Not just 45-I was just using as an example.
    So a user selects a number of days on a scroll bar and then it displays it in week,days etc.
    This reply could possibly be the quintessential example of why this forum does not and should not do other peoples homework.
    <--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
    If topic has been resolved, please pull down the Thread Tools & mark it Resolved.


    Is VB consuming your life, and is that a bad thing??

  7. #7

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    60

    Re: Mod Help

    Its not homework as such... Cause we are only doing like very basic stuff. By this i mean VERY BASIC -i.e--the rest of the class is still having problems changeing colours of labels with cmd buttons. I'm doing a extension thing!

    Thanks Seenu... I worked it out with some of your code. I wanted 3 labels
    Thanks

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