Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros entornos y lenguajes > .NET
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 29-10-2023
tsk tsk is offline
Miembro
 
Registrado: dic 2017
Posts: 52
Poder: 7
tsk Va por buen camino
En que sentido se complica

Código PHP:
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Text.RegularExpressions;

public class 
Ventana Form
{
    private 
Button b;
    private 
TextBox txtBox_I;
    private 
TextBox txtBox_O;
    private 
TextBox txtBox_L;
    private 
TextBox txtBox_B;
    private 
TextBox txtBox_V;
    private 
TextBox txtBox_F;
    private 
TextBox txtBox_H;
    private 
TextBox txtBox_R;
    private 
TextBox txtBox_S;
    
    static public 
void Main()
    {
        
Application.Run(new Ventana());
    }

    private 
Ventana()
    {
        
= new Button();
        
b.Text "Click Me!";
        
b.Click += new EventHandler (Button_Click);
        
Controls.Add(b);

        
txtBox_I = new TextBox();
        
txtBox_I.Text "";
        
txtBox_I.Location = new Point(10,20);
        
Controls.Add(txtBox_I);

        
txtBox_O = new TextBox();
        
txtBox_O.Text "";
        
txtBox_O.Location = new Point(10,40);
        
Controls.Add(txtBox_O);
        
        
txtBox_L = new TextBox();
        
txtBox_L.Text "";
        
txtBox_L.Location = new Point(10,60);
        
Controls.Add(txtBox_L);

        
txtBox_B = new TextBox();
        
txtBox_B.Text "";
        
txtBox_B.Location = new Point(10,80);
        
Controls.Add(txtBox_B);

        
txtBox_V = new TextBox();
        
txtBox_V.Text "";
        
txtBox_V.Location = new Point(10,100);
        
Controls.Add(txtBox_V);

        
txtBox_F = new TextBox();
        
txtBox_F.Text "";
        
txtBox_F.Location = new Point(10,120);
        
Controls.Add(txtBox_F);

        
txtBox_H = new TextBox();
        
txtBox_H.Text "";
        
txtBox_H.Location = new Point(10,140);
        
Controls.Add(txtBox_H);

        
txtBox_R = new TextBox();
        
txtBox_R.Text "";
        
txtBox_R.Location = new Point(10,160);
        
Controls.Add(txtBox_R);

        
txtBox_S = new TextBox();
        
txtBox_S.Text "";
        
txtBox_S.Location = new Point(10,180);
        
Controls.Add(txtBox_S);
    }

    private 
void Button_Click(object senderEventArgs e)
    {
        
string pattern1 = @"#I(.*)O(.*)L(.*)B(.*)V(.*)F(.*)H(.*)R(.*)S(.*)";
         
Regex rx = new Regex(pattern1,
                
RegexOptions.Compiled RegexOptions.IgnoreCase);

        
string text "#I225.7O226.2L006B100V25.7F50.2H50.2R0080S€„€ˆ„À";

        
MatchCollection matches rx.Matches(text);
        
txtBox_I.Text matches[0].Groups[1].Value;
        
txtBox_O.Text matches[0].Groups[2].Value;
        
txtBox_L.Text matches[0].Groups[3].Value;
        
txtBox_B.Text matches[0].Groups[4].Value;
        
txtBox_V.Text matches[0].Groups[5].Value;
        
txtBox_F.Text matches[0].Groups[6].Value;
        
txtBox_H.Text matches[0].Groups[7].Value;
        
txtBox_R.Text matches[0].Groups[8].Value;
        
txtBox_S.Text matches[0].Groups[9].Value;
        
        
MessageBox.Show("Ya se procesó la cadena");
    }

Responder Con Cita
  #2  
Antiguo 29-10-2023
REHome REHome is offline
Miembro
 
Registrado: jul 2003
Ubicación: España
Posts: 454
Poder: 21
REHome Va por buen camino
Me funciona de maravilla.

Código:
using System;
using System.Text.RegularExpressions;
using System.Windows.Forms;

namespace Termite_SAI_01
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button_Enviar_Click(object sender, EventArgs e)
        {
            string expresionRegular = @"#I(.*)O(.*)L(.*)B(.*)V(.*)F(.*)H(.*)R(.*)S(.*)";
            Regex rx = new Regex(expresionRegular,
                   RegexOptions.Compiled | RegexOptions.IgnoreCase);

            string texto = "#I225.7O226.2L006B100V25.7F50.2H50.2R0080S€„€ˆ„À";

            MatchCollection matches = rx.Matches(texto);
            textBox_I.Text = matches[0].Groups[1].Value;
            textBox_O.Text = matches[0].Groups[2].Value;
            textBox_L.Text = matches[0].Groups[3].Value;
            textBox_B.Text = matches[0].Groups[4].Value;
            textBox_V.Text = matches[0].Groups[5].Value;
            textBox_F.Text = matches[0].Groups[6].Value;
            textBox_H.Text = matches[0].Groups[7].Value;
            textBox_R.Text = matches[0].Groups[8].Value;
            //textBox_S.Text = matches[0].Groups[9].Value;

            MessageBox.Show("Ya se procesó la cadena");
        }
    }
}
Muchas gracias mi muy distinguido amigo.
__________________
http://electronica-pic.blogspot.com....n-arduino.html Manuales de electrónica general, PIC y Arduino.
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
decodificar datos recibidos por COM jesmasuso Varios 1 29-11-2014 00:35:03
Almacenar datos recibidos del Tcomport jgarcias2 OOP 0 18-04-2011 00:35:48
Quitar datos recibidos de un puerto serial GrupoDatasoft OOP 3 05-09-2008 16:31:37
Quitar datos recibidos de un puerto serial GrupoDatasoft Varios 3 05-09-2008 16:30:14
Quitar datos recibidos de un puerto serial GrupoDatasoft API de Windows 1 05-09-2008 16:11:51


La franja horaria es GMT +2. Ahora son las 10:19:49.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi