|
-
Jul 26th, 2011, 01:59 AM
#1
Thread Starter
Member
[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
-
Jul 26th, 2011, 02:21 AM
#2
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
-
Jul 26th, 2011, 02:28 AM
#3
Thread Starter
Member
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.
-
Jul 26th, 2011, 02:49 AM
#4
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
-
Jul 26th, 2011, 10:27 AM
#5
Re: Mod Help
 Originally Posted by homer5677
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.
-
Jul 26th, 2011, 09:37 PM
#6
Re: Mod Help
 Originally Posted by homer5677
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?? 
-
Jul 27th, 2011, 01:02 AM
#7
Thread Starter
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|