Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Reading from a currency counter
Message
De
06/12/2015 08:52:49
 
 
À
06/12/2015 03:30:59
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 9.0
OS:
Windows 10
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01628506
Message ID:
01628543
Vues:
34
>>>>>>>OTOH maybe just setting the TextBox.Multiline = true ?
>>>>>>
>>>>>>Bingo!
>>>>>>That was the answer, Viv.
>>>>>>I tried that and it gave me what I needed.
>>>>>>It's interesting that when Multiline is set to false, the carriage returns disappear, but they're preserved when it's set to true. I'm sure that there's some logic there, but it escapes me.
>>>>>>That gave me me what I needed to separate the amounts.
>>>>>>Thanks, Viv
>>>>>
>>>>>Glad it was so easy :-}
>>>>
>>>>
>>>>Here's another question, Viv
>>>>
>>>>
>>>>string[] moneylines = Regex.Split(frmCounting.textBoxDemoninations.Text, "\r\n");
>>>>workingprocessds.depdetail[0].ones = Convert.ToDecimal(moneylines[0].TrimEnd().TrimStart());
>>>>workingprocessds.depdetail[0].twos = Convert.ToDecimal(moneylines[1].TrimEnd().TrimStart());
>>>>workingprocessds.depdetail[0].fives = Convert.ToDecimal(moneylines[2].TrimEnd().TrimStart());
>>>>workingprocessds.depdetail[0].tens = Convert.ToDecimal(moneylines[3].TrimEnd().TrimStart());
>>>>workingprocessds.depdetail[0].twentys = Convert.ToDecimal(moneylines[4].TrimEnd().TrimStart());
>>>>workingprocessds.depdetail[0].fiftys = Convert.ToDecimal(moneylines[5].TrimEnd().TrimStart());
>>>>workingprocessds.depdetail[0].hundreds = Convert.ToDecimal(moneylines[6].TrimEnd().TrimStart());
>>>>workingprocessds.depdetail.AcceptChanges();
>>>>
>>>>This code successfully parses the text into the 7 correct denominations.
>>>>
>>>>For testing, I activate this code by pressing a command button.
>>>>Is there any way that I can force this code to be activated automatically after the multiline textbox is filled?
>>>
>>>What type of TextBox - Winforms, Web, WPF ?
>>>How does it get populated ?
>>
>>It's a Winform textbox.
>>
>>It is populated when someone puts the cursor in the upper lefthand corner and runs a currency counting machine attached to a serial port on the PC.
>>The serial stream is read by proprietary software that converts it into simulated keystrokes.
>>When reading the stream the textbox behaves exactly as it would if a human keyed in a quantity and hit Enter, and repeated that keystroke combination 6 more times.
>>
>>The appearance of the screen is identical and so is the value to the text.property of the textbox.
>>
>>If there is no quantity for a denomination, it sends a zero followed by Enter, so there are always 7 quantities and 7 Enters.
>
>Maybe watching OnTextChanged would work ? e.g:
protected override void OnTextChanged(EventArgs e)
>        {
>            if (this.Text.Count(t => t == '\n' ) == 7)
>            {
>                DoConversion(this.Text);
>                this.Text = String.Empty;
>            }
>
>            base.OnTextChanged(e);
>        }
>You could create a custom control sub-classed from Textbox if you are using it in more than one place.....

I was thinking of something along that line.
Your solution is more elegant than what I had in mind, though.
I'll try it
Anyone who does not go overboard- deserves to.
Malcolm Forbes, Sr.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform