|
Hi Friends,
I am working on access card . Its working fine. It reading when i am clicking on button. I have written the code in the button click only. I dont know in which event it reads automatically. Please tell me that in which event it will read when i touch the access card to the controller.
I want the event only. Please let me know asap.
Its RS232 micro controller.
Thanks in advance,
Vinod gupta
modified on Wednesday, July 30, 2008 8:34 AM
|
|
|
|
|
Which interface do you use ?
I was working in a barcode scanner using RS232, it's using SerialPort Class.
In that class, I can use event "DataReceived" to detect a new barcode.
|
|
|
|
|
Thanks alot for replying.
Ya its RS232 micro controller. I am not getting that in which event it will read the data when i touch the access card to the microcontroller.
Please help me out.
Thanks...
|
|
|
|
|
If you're using the SerialPort then remember to set the ReceivedBytesThreshold low enough to generate the event.
Scott P
“It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.”
-Edsger Dijkstra
|
|
|
|
|
Hi,
I have a datatable ParentTable that contains 100 records
I created a Dataview that selects only UK users
Dataview dvUK=ParentTable.DefaultView();
dvUK..RowFilter= "Country='UK'";
now in my dataiview dvUK have 30 records
I want to copy all these 30 records to some other table(dtChildUK) that have same structures as the ParentTable
DataTable dtChildUK=ParentTable.Clone();
How to copy all the 30 rows ( rows from dataview) to dtChildUK
|
|
|
|
|
Try this after applying the filter to the DataView:
<br />
foreach (DataRowView rowView in dvUK)<br />
{<br />
dtChildUK.Rows.Add(rowView.Row);<br />
}<br />
Fernando Mendes
Senior .NET Developer, Architect
|
|
|
|
|
|
Hello
You can use only this method of dv:
DataTable dtChildUK=dvUK.ToTable();
Simple and efficient.
Be Happy
Syed Shahid Hussain
|
|
|
|
|
Hey all,
I'm just trying to figure out why this bubble sort algorithm is ignoring the last element of the array.
namespace Bubble_sort
{
class SortArray
{
void BubblesortArray(int[] array)
{
int Position = 0;
int endpos = 0;
bool swapped = true;
while (swapped)
{
swapped = false;
Position = 0;
endpos = array.Length;
while (Position < endpos)
{
if (array[Position] > array[Position + 1])
{
int Temp = array[Position];
array[Position] = array[Position + 1];
array[Position + 1] = Temp;
swapped = true;
}
Position++;
endpos--;
}
for (int i = 0; i < array.Length; i++)
{
Console.Write(array[i].ToString() + ", ");
}
Console.WriteLine();
}
}
public static void Main(string[] args)
{
SortArray Sort = new SortArray();
int[] a = {1, 2, 3, 4, 1, 45, 134, 762, 2};
Sort.BubblesortArray(a);
for (int i = 0; i < a.Length; i++)
{
Console.Write(a[i].ToString() + ", ");
}
Console.Read();
}
}
}
thats the code (its a console app).
I do this out of curiosity, and annoyance( ) but i would like any help you could offer me.
Thankyou.
|
|
|
|
|
I'm hesitant to just give you the answer because this is a classic homework problem. Instead I'll give you some hints. (You'll feel better if you solve it yourself anyway)
Start by attaching a debugger and stepping through the code in the bubble sort routine line by line.
Each pass of a bubble sort should compare each adjacent pair of values. This routine doesn't. Look closely at the indexes you are using to the array being sorted. (Put watches on the values)
Simon
|
|
|
|
|
Thankyou for your help, simon. I suppose it does look like a homework problem my apologies for making it so. But the only reason I asked this is the site where I got it from has it written in a similar way i was just trying to figure out why the program didnt work.
Again my apologies.
|
|
|
|
|
No need to apologise. It's not your fault, it's a common question.
Did you manage to figure it out?
Simon
|
|
|
|
|
Yes I did thank you Simon. The step through debugger in VS took a little while to get used to but eventually it worked a treat. And i figured it out.
So, as always, logic prevailed over the human condition.
|
|
|
|
|
Hi,
i want to sepearte and count the string
s="aacbbcccddehgvfdd"
i need the Outputlike,
aa
bb
dd
dd
Count =4.
My question is : how will i get the out like the above
Please answer any one
|
|
|
|
|
What are you counting? Pairs of letters?
Just loop through the string, searching for pairs and keeping count.
Simon
|
|
|
|
|
Simon Stevens wrote: What are you counting? Pairs of letters?
All of them, yes!
|
|
|
|
|
leppie wrote: Simon Stevens wrote:
What are you counting? Pairs of letters?
All of them, yes! [Poke tongue]
But seemingly only explicit pairs (the 'ccc's are ignored).
In which case, loop through each character. For each character, if it matches the next one, but not the one after, then count it and move on. If you reach a repeated string of the same chars, jump over them all, and don't count them.
Simon
|
|
|
|
|
public static System.Collections.Generic.List<string>
FindSequences
(
string Chars
,
uint Length
)
{
System.Collections.Generic.List<string> result =
new System.Collections.Generic.List<string>() ;
char current = '\0' ;
int count = 0 ;
foreach ( char c in Chars )
{
if ( c != current )
{
if ( count == Length )
{
result.Add ( new string ( current , count ) ) ;
}
current = c ;
count = 0 ;
}
count++ ;
}
if ( count == Length )
{
result.Add ( new string ( current , count ) ) ;
}
return ( result ) ;
}
Though it'll fail when Length==0
|
|
|
|
|
Hi,
I'm new to C# and .Net architecture , so sorry about the silly question.... .
I'm using a grid control in order to display data from the data base.
My problem is when the user press the CTRL+C in a specific cell in order to copy the data
to a different cell.
The result is that the new cell contain the data of the entire row , instead of the data of the copied cell.
note that if I use the mouse right click and "copy" <-> "paste" it is working fine.
My question is how can I capture the CTRL+C and CTRL+V with the keyboard?
With best regards,
Eli
|
|
|
|
|
Are you talking about the DataGridView control? I don't seem to be having any sort of problem with CTRL-C, CTRL-V to copy and paste from cell to cell with that control.
Anyways, you might take a look at the grid's KeyDown event and see if you can use the e.Modifiers to capture the Control key, and e.KeyCode to capture the 'C' or 'V', but, to be honest, I don't think that event will trigger in an editable cell of the DataGridView. The other option I can think of is to override ProcessCmdKey and see if you can capture the key combinations there.
|
|
|
|
|
Some methods in the framework take the name of a method as a string, e.g. ObjectDataSource and most of WPF. I don't like this as the compiler and IDE tools can't link the string and the method. So I want to generate the string from the token. I came up with this:
class TestClass
{
public static void Test()
{
string s = GetName<string,int>( Method );
}
static int Method( string s ) { return 0; }
static string GetName<T,TResult>( Func<T,TResult> method )
{
return method.Method.Name;
}
...
GetName overloads for Actions and Funcs
...
}
This is ok, but I don't like having to specify the generic types when calling GetName .
I don't think there's a way around this, because method groups don't participate in type inferencing.
So my question is: is there a better way?
Thanks
Nick
----------------------------------
Be excellent to each other
|
|
|
|
|
Although not exactly what you are looking for, but at least a bit more generic:
class TestClass
{
public static void Test()
{
string s = GetName( new Func<string,int>(Method));
}
static int Method(string s) { return 0; }
static string GetName(Delegate method)
{
return method.Method.Name;
}
}
I will try think of a better way
|
|
|
|
|
Thanks leppie, that is better.
You can also just use a cast:
string s = GetName( ( Func<string,int> ) Method );
But this doesn't work:
string s = GetName( ( Delegate ) Method );
----------------------------------
Be excellent to each other
|
|
|
|
|
Are you trying to get the method name from the method itself?
If so:
System.Reflection.MethodBase.GetCurrentMethod().Name
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Yes, but then he would have to call the method!
|
|
|
|