Solved

Control of Number in textbox

Posted on 2007-11-18
3
210 Views
Last Modified: 2010-04-30
Hi I have 7 txtboxs one for each days order the code below has a txtbox called txtTotalOrders.Text once i enter a number in this box it is divided equally in the boxs dependent on what day it is i.e if it is Tuesday then the number is only divided between Tuesday to Saturday. The problem is I need the resulted number from the division to be rounded up or down to the nearest whole number. Any ideas??

Thanks
Andy


Private Sub txtTotalOrders_Change()
Dim intTotal As Integer
Dim dblDaily As Double

intTotal = CInt(txtTotalOrders.Text)



Select Case Weekday(Now)

Case 1
dblDaily = intTotal / 7

For i = 0 To 6
   txtDays(i) = dblDaily
Next i


Case 2
dblDaily = (intTotal) / 6

For i = 1 To 6
   txtDays(i) = dblDaily
Next i

Case 3
dblDaily = (intTotal) / 5

For i = 2 To 6
   txtDays(i) = dblDaily
Next i

Case 4
dblDaily = (intTotal) / 4

For i = 3 To 6
   txtDays(i) = dblDaily
Next i


Case 5
dblDaily = Round(intTotal) / 3

For i = 4 To 6
   txtDays(i) = dblDaily
Next i


Case 6
dblDaily = (intTotal) / 2

For i = 5 To 6
   txtDays(i) = dblDaily
Next i

Case 7
dblDaily = (intTotal)

For i = 6 To 6
   txtDays(i) = dblDaily
Next i

End Select

End Sub
0
Comment
Question by:samandrew
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 400 total points
ID: 20308012
If you declare dblDaily as Integer, it will automatically round to the nearest integer, if that's what you mean.
0
 

Author Comment

by:samandrew
ID: 20308259
Hi Graham

Oh so easy when u know what your are doing

Thanks again

Andy
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 20308387
Hehe.
I though I had completely misunderstood the question :). Never mind, you're learning fast.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question