|
How about looping all tables from the database. (export)
Saving them in an xml document. (export file)
And then saving them back to another database. (import)
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
How i can define dyamic array in c#?
|
|
|
|
|
Use a List?
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
System.Collections.ArrayList al = new ArrayList();
Then for every element you want to add just use the a1.Add method.
|
|
|
|
|
Only if you are forced to use .NET 1.1
|
|
|
|
|
As HArold said, only if forced to use 1.1. The problem with an ArrayList is it requires every object to be converted to and from object (boxing/unboxing). A List<T> gives the same functionality, but without that overhead and inconvenience!
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Ah, okay, gotcha! I was typing asking why it was bad!
Thanks for the tip!
|
|
|
|
|
I have made a custom Scroll Bar somewhat like the one here How to skin scrollbars for Panels, in C#[^].
My Goal is to insert this control inside of a treeview and get rid of the standard scrollbar. I have been working and looking around for answers for two weeks. Could someone please help me out or at least point me in the correct direction
Mike
|
|
|
|
|
Hi Guys,
Hope someone can help with this little problem I have because its driving me mad.
I need to calculate the period in which a date falls
so lets say a companies financial years starts on 1st Jan then
Jan = P1, Feb = P2 etc etc
That makes finding the period quite easy, i just take the month of the transaction.
The problem I'm having is when the FY starts on say 1st April 2009 then
Apr = P1, May = P2 etc etc
So .
15/06/2009 returns P3/2009
01/08/2009 returns P5/2009
but
15/01/2009 returns P10/2008
So far I'm using this
'Holds the date which financial year starts
Dim FYstart As Date = = CDate("01/04/2000")
'Move FYStart to current year
FYstart = DateValue(FYstart.Day & "/" & FYstart.Month & "/" & TranDate.Year)
'Months difference between transaction date and FYstart
Dim MonthDiff As Integer = -DateDiff(DateInterval.Month, TranDate, FYstart)
'Years different between the 2 dates
Dim YearDiff As Integer = Math.Truncate(MonthDiff / 12)
'Period number
Dim p As Integer
If MonthDiff <= 0 Then
p = 12 + (MonthDiff)
Else
p = MonthDiff
End If
Period = p
Year = TranDate.Year + YearAdj
Anyone have any pointers because everytime I think I've cracked it, I try a different FY Start / Tran Date combination and it gives me wrong answer
thanks in advance,
Daniel
|
|
|
|
|
Oops - you posted in the C# forum!
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
drodgers wrote: but
15/01/2009 returns P10/2008
This is right. January is the tenth month of the 2008/09 tax year.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Would something this simple not work....
DateTime startDate = new DateTime(2009, 04, 01);
DateTime transactionDate = new DateTime(2009, 4, 01);
int monthDiff = transactionDate.Month - startDate.Month + 1;
if (monthDiff <= 0)
monthDiff = 12 + monthDiff;
MessageBox.Show(monthDiff.ToString());
|
|
|
|
|
Hello, I'm creating a program that will parse a for loop statement. I'm already done with some of the things that a parser does. Now my problem is about the pattern i created to check if the user's for loop syntax is correct.
First i ask the user to enter an example of a for loop statement syntax.
ex. for(int x=0; x<5; x++) Console.WriteLine("Hello World");
After that I'll just check if the example follows the syntax of a for loop statement.
To check if the syntax is correct i created a for loop statement pattern to compare it with the user's for loop statement.
Here is the pattern:
public static string forLoopPattern =
@"([for])" +
@"([(])" +
@"([int]\ \\)" +
@"([a-z])" +
@"([=])" +
@"([0-9])" +
@"([;])" +
@"([a-z])" +
@"([>,<,=,<=,>=,=<,=>])" +
@"([0-9])" +
@"([;])" +
@"([a-z])" +
@"([++,--])" +
@"([)])";
Is that pattern correct? If not what should i change or do to make it correct? Also, i don't know yet if that pattern really works or not. How will i be able to check if that pattern works?
Please Help..thanks..
|
|
|
|
|
You really should test it yourself and see if it works.
Some points thou...
- for loops don't rely on using an int data type
- someone may want two spaces between type and instance name
- instance names can be alot more than just a-z
- instance name can be any number (within limits of data type) and potentially negative too
- you can also apply more than just increment and decrements to the instance
etc...
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Further to what musefan said, broadly speaking, each of the three parts of the for loop control can contain an expression, with the first also being allowed to contain a variable declaration and the second being required to result in a boolean value.
Thus it would be legal to have the following:
...
for (MyObj = new MyObj(); MyObj; MyObj.MoveNext())
{
...
}
...
provided that MyObj implements an implicit bool conversion operator.
You can check out the C# language specification for the exact rules for the formation of a for loop; see section 8.8.3 of the C# Language Specification 1.2.doc, which you can find in your VS folder, in VC#\Specifications\1033.
|
|
|
|
|
And can also include the little-known , (COMMA) operator.
|
|
|
|
|
I thought that was only in C++? I don't know for sure though... I am at home now.
Cheers,
Vikram. (Proud to have finally cracked a CCC!) Recent activities:
TV series: Friends, season 10
Books: Fooled by Randomness, by Nassim Nicholas Taleb. Carpe Diem.
|
|
|
|
|
It seems C# limits it somehow, and I'm reading the spec now to see why.
"
8.8.3 The for statement
The for statement evaluates a sequence of initialization expressions and then, while a condition is true, repeatedly executes an embedded statement and evaluates a sequence of iteration expressions.
for-statement:
for ( for-initializer ; for-condition ; for-iterator ) embedded-statement
"
for ( int i = 0 ; i < 10 ; i++ , i++ )
{
System.Console.WriteLine ( i ) ;
}
or
int i ;
for ( i = 0 , i++ ; i < 10 ; i++ , i++ )
{
System.Console.WriteLine ( i ) ;
}
The comma operator is valid in the for-iterator, but not in the for-initializer and for-condition (they are allowed there in C), this may be an oversight.
I may ask on an MSDN forum later.
|
|
|
|
|
Yeah, you're right. Turns out you can even do multiple declarations:
for ( int i = 0, j = 4 ; i < 10; i++ , i++, j++ )
{
System.Console.WriteLine ( i + " " + j) ;
}
Another arcane fact about C# that I'll probably never use in my life
Cheers,
Vikram. (Proud to have finally cracked a CCC!) Recent activities:
TV series: Friends, season 10
Books: Fooled by Randomness, by Nassim Nicholas Taleb. Carpe Diem.
|
|
|
|
|
Yeah, obfuscation.
I checked and it's been like that since v1.1
|
|
|
|
|
Maybe you're right. I see no mention of the comma operator in either C# spec.
C-74 (Dennis Ritchey)
"
7.15 expression , expression
A pair of expressions separated by a comma is evaluated lefttoright
and the value of the left expression is discarded.
The type and value of the result are the type and value of the right operand. This operator groups lefttoright.
It should be avoided in situations where comma is given a special meaning, for example in actual arguments
to function calls (§7.1.6) and lists of initializers (§10.2).
"
C-99 (ANSI)
"
The left operand of a comma operator is evaluated as a void expression; there is a
sequence point after its evaluation. Then the right operand is evaluated; the result has its
type and value.95) If an attempt is made to modify the result of a comma operator or to
access it after the next sequence point, the behavior is undefined.
"
But C# has no comma operator, the effect is provided by:
C# (ECMA)
"
statement-expression:
invocation-expression
object-creation-expression
assignment
post-increment-expression
post-decrement-expression
pre-increment-expression
pre-decrement-expression
statement-expression-list:
statement-expression
statement-expression-list , statement-expression
"
And that's not allowed in the for-condition.
|
|
|
|
|
Ah...ok...thanks about that....
Now, my other problem is how to use the symbols '^', '?', '*', \s, \t, \n to include in the pattern. i already read how they work. its just that i don't know where to put them to make the pattern correct.
for example:
@"([for]\s*)";
is the location of the \s* correct? if not, where should i put it? Can anyone give me suggestions on where to put those things in the pattern...
|
|
|
|
|
Creating a pattern matching system for even a basic "For" loop is very complex, and would be rather more detailed that your example. For example, consider these cases which are legal, but which fail your existing pattern:
for (int i=0;i<9;i++)
for(int i=0;i<10;i++)
for(int i=0;i<9;i+=2)
for(i=1;i<9;i++)
for(int i=0;i<array.Length;i++)
for(int index=0;index<array.Length;index++)
and the following which passes, but which is not a good idea
for(int i=0;j<10;k++)
I suggest you have a look at Extended Backus-Naur form which is a metalanguage for describing languages!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
gamer1127 wrote: Is that pattern correct?
No. It's perfectly possible to have a statement that reads
for ( ; ; ) . Using a regular expression is not an effective method to accomplish this - a better method would be to use an Abstract Syntax Tree[^].
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Now that you mentioned the Abstract Syntax Tree, I remember that we are required to use what they call a parse tree. is that also the same with Abstract Syntax Tree?
|
|
|
|