|
The class you're passing back and forth would have to be defined in another DLL, that your other DLL would then "use".
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
What I have done so far is included the Class "PumpTest" (Class full of variables) in both the client and the DLL and attempted to use the code
"pTest = Calc.TableIIcalc(pTest); " to pass the PumpTest pTest to the DLL.
My DLL looke like this
public PumpTest TableIIcalc(PumpTest pTest)
{
calculations
return pTest;
}
I planned on making the PumpTest class its own DLL, would that solve the problem?
|
|
|
|
|
What makes you think this will not work?
You can only be young once. But you can always be immature.
- Dave Barry
|
|
|
|
|
Well I get two errors with the "pTest = Calc.TableIIcalc(pTest);" line of code
The first is a invalid arguments error, the second is Argument '1', cannont convert from 'Namespace.PumpTest' to 'Namespace2.PumpTest' they aren t actually called namespace but I cant post too much info about the program on the web. Namespace is the name of the client and namespace two is the name of the DLL.
|
|
|
|
|
Hello,
I'm stuck with the following issue:
let's say there is a DateTime 'timepoint', wich is passed in my method. I need to check now, whether timepoint's DayOfWeek is between 'fromDayOfWeek' and 'toDayOfWeek'.
that's what I've done so far:
protected override bool checkTimepoint(DateTime timepoint, DayOfWeek from, DayOfWeek to)
{
bool retValue;
retValue = timepoint.DayOfWeek >= from && timepoint.DayOfWeek <= to;
return retValue;
}
This will work for ranges like Monday-Friday, Thursday-Wednesday, Wednesday-Wednesday, but it will fail for something like Saturday-Sunday, since Sunday (0) is lower than Saturday(6).
Any idea on how to logically implement this issue?
Thanks in advance.
|
|
|
|
|
We solved a similar problem by using a mapping from DayOfWeek to integer that returned 7 instead of 0 for Sunday.
This way your code would work, too.
Not very nice but it works.
For .net the week start on Sunday
-^-^-^-^-^-^-^-
no risk no funk
|
|
|
|
|
This will fix the problem for Saturday-Sunday, but it will not solve for Saturday-Tuesday.
|
|
|
|
|
why not:
protected override bool checkTimepoint(DateTime timepoint, DayOfWeek from, DayOfWeek to)
{
return timepoint.DayOfWeek >= from && timepoint.DayOfWeek <= to;
}
-Spacix
All your skynet questions[ ^] belong to solved
I dislike the black-and-white voting system on questions/answers.
|
|
|
|
|
because this doesn't work.
testcase:
timepoint = new DateTime(2008,5,4);//sunday, 0
from = DayOfWeek.Friday; // 5
to = DayOfWeek.Tuesday; // 2
return 0 >= 5 && 0 <= 2;
return value is 'false', but sunday is between friday and tuesday!
|
|
|
|
|
You can use the CultureInfo class to set the first day of the week.
using System.Threading;
Thread.CurrentThread.CurrentCulture.DateTimeFormat.FirstDayOfWeek = DayOfWeek.Sunday;
So, set the first day of the week to whatever day you want, and then do your comparison.
protected override bool checkTimepoint(DateTime timepoint, DayOfWeek from, DayOfWeek to)
{
Thread.CurrentThread.CurrentCulture.DateTimeFormat.FirstDayOfWeek = from;
bool inRange = timepoint.DayOfWeek >= from && timepoint.DayOfWeek <= to;
Thread.CurrentThread.CurrentCulture.DateTimeFormat.FirstDayOfWeek = DayOfWeek.Sunday;
return inRange;
}
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
modified on Friday, May 2, 2008 1:26 PM
|
|
|
|
|
Huh, interesting.
I wonder how it performs in a loop.
|
|
|
|
|
If performance is an issue (in a loop), you could always wait until the loop is done and reset to the proper 1st day at that point, thus saving n calls to do it in that checkpoint function.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Just thought I'd let you know I was completely wrong.
I posted a new response to the OP with the correct solution.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
What? Say it ain't so! 
|
|
|
|
|
return ( true ) ;
Every timepoint falls between some DayOfWeek X and some DayOfWeek Y.
buchstaben wrote: Thursday-Wednesday
Did you mean that?
If you want Sunday to sort higher than Saturday, then you can simply add seven to it, but you'll need to store the values as integers rather than as the provided enum values.
int x = (int) timepoint.DayOfWeek ;
int y = (int) from ;
int z = (int) to ;
x += x==0 ? 7 : 0 ;
y += y==0 ? 7 : 0 ;
z += z==0 ? 7 : 0 ;
return ( x >= y && x <= z ) ;
but that's rather ugly.
|
|
|
|
|
You can set the first day of the week to be thursday, and then the comparison would work.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Ignore my first post. This is the best way (notice no bizarre culture crap going on):
DayOfWeek from = DayOfWeek.Thursday;
DayOfWeek to = DayOfWeek.Tuesday;
DayOfWeek currentDay = DayOfWeek.Wednesday;
bool inRange = (currentDay >= from || currentDay <= to);
Notice that I'm using OR instead of AND . If you make currentDay Wednesday, inRange will be false. If you make it any other day, it will be true.
It's kind of pointless to do a Sunday-Saturday (or similar) comparison because any date will fall into the range. BTW, the comparison above also works for from=Saturday and to=Sunday.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I was just reviewing a method I wrote a few months back where I was checking to see if a value (integer) is between two others. I decided I needed more than a true/false, there are (currently) four result values:
[System.FlagsAttribute()]
public enum CheckRangeResult
{
WithinStrictRange = 0
,
Low = 1
,
High = 2
,
WithinLooseRange = 3
}
Basically; given Min, Max, and Test we expect Min to be less than Max; and Test will be Lower than Min (1), Higher than Max (2), or WithinStrictRange (0).
But, when Min is greater than Max and Test is between Min and Max, both tests are true, yielding WithinLooseRange (3).
In the case presented here, when Min is greater than Max and Test is not between the values, that should translate to "true", but that's not currently supported.
I think I need to add value 4 to indicate that Min is greater than Max, then WithinLooseRange would have value 7. I'll think about it over the weekend.
|
|
|
|
|
It occurred to me late today that this might make a good Friday Programming Quiz. 
|
|
|
|
|
Maybe even two questions...
1) Given the following:
DayOfWeek startDay = DayOfWeek.Thursday;
DayOfWeek endDay = DayOfWeek.Monday;
DayOfWeek currentDay = DayOfWeek.Wednesday;
Write a C# publicly accessible function that determines whether or not the day falls between startDay and endDay . The function should work for any combination of startDay /endDay values, and should return a boolean value (true if in range, false if not in range).
Answer:
public bool DateInRange(DayOfWeek currentDay, DayOfWeek startDay, DayofWeek endDay)
{
return (currentDay >= startDay || currentDay <= endDay);
}
2) Given the function above, change the function so that the class encapsulating it does not have to be instantiated in order to use the function.
Answer:
public static bool DateInRange(DayOfWeek currentDay, DayOfWeek startDay, DayofWeek endDay)
{
return (currentDay >= startDay || currentDay <= endDay);
}
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I don't think that works with the "normal" case where startDay < endDay.
It's also not a very general solution (which is no crime).
Given a number (value) line, two points on that line that define a range, and another point to test inclusion.
Normal
...........
1 > 2 < 3
Inverted (endponts not in normal order)
...........
4 < 5 > 6
The test value could be in any of the spots labeled 1 - 6.
We then need to assign true/false to these spots.
Clearly 2 yields true, while 1 and 3 yield false.
The question is about the inverted range;
The OP needs to assign true to 4 and 6, false to 5.
The code I wrote in November was designed to allow assigning true to 5, false to 4 and 6.
I have now modified my helper method (and enum) so it returns one of six values (it was four previously).
The application then needs to provide a method that handles the translation to true/false.
|
|
|
|
|
I think this should cover it then...
public static void DayInRange(DayOfWeek currentDay, DayOfWeek startDay, DayOfWeek endDay)
{
if (startDay == endDay)
{
return true;
}
if (startDay < endDay)
{
return (currentDay >= startDay && currentDay <= endDay);
}
return (currentDay >= startDay || currentDay <= endDay);
}
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
That hurts my eyes.
(Not that I should talk. )
|
|
|
|
|
On keypress event i am disallow some of the some of the ascii value
like this
if (((e.KeyChar >= 91 && e.KeyChar <= 96) || e.KeyChar == 123 || e.KeyChar == 124 || e.KeyChar == 125 || e.KeyChar == 42 || e.KeyChar == 33 || e.KeyChar == 35 || e.KeyChar == 38 || e.KeyChar == 40 || e.KeyChar == 39 || e.KeyChar == 34 || e.KeyChar == 41 || e.KeyChar == 44 || e.KeyChar == 64 || e.KeyChar == 61 || e.KeyChar == 59 || e.KeyChar == 58 || e.KeyChar == 63 || e.KeyChar == 60 || e.KeyChar == 62) != false)<br />
{<br />
e.Handled = true;<br />
<br />
}
Now hat i want when user press space bar (Ascii value 32) then it will print '~' (Ascii value 126) in place of Ascii 32
if user enter
ABCD(SPACE)FGT THEN IT SHOULD PRINT
ABCD~FGT
|
|
|
|
|
Hi,
You may use the following code:
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyCode = Keys.Space Then
e.SuppressKeyPress = True
Dim i As Integer
i = Me.TextBox1.SelectionStart
Me.TextBox1.Text = Me.TextBox1.Text + "~"
Me.TextBox1.SelectionStart = i + 1
End If
End Sub
Hope this helps.
Vinay
ComponentOne LLC.
www.componentone.com
|
|
|
|