|
602
|
Programación / Programación Visual Basic / Manual de prueba VC++ y VB sobre RS232
|
en: 28 Febrero 2009, 19:44 pm
|
Hola: Estoy haciendo la continuación del manual sobre Visual C# de la parte de MonoDevelop 1 bajo Linux, por otro lado algo de Visual C++ y Visual Basic. El único código funcional es el VC++, el VB funciona aunque no está publicado porque está hecho a la chapuza. Cuando lo haga seriamente lo publico en el manual. Si alguien quiere ese código ya, me lo dicen y lo pongo aquí, funciona, pero no es el adecuado, hay otro método que estoy averiguando en hacerlo más cómodo y con menos código. El manual no está acabado, sólo verán su estilo a ver si les gusta y yo mismo ver sus sugerencias. DESCARGAR Manual PDFUn cordial saludo.
|
|
|
603
|
Programación / .NET (C#, VB.NET, ASP) / Activar un comando al cerrar la aplicación.
|
en: 24 Febrero 2009, 18:34 pm
|
Hola: Tengo un código hecho con Visual C# Express. Se trata de que uso el puerto serie, si pulso un botón dejo la comunicación activa, si cierro el programa principal, el dato enviado por el puerto serie que lleva hasta un PIC16F84A está activo, antes de cerrar el programa debo pulsar el otro botón para desactivar el PIC por el puerto serie. Me gustaría saber si hay una posibilidad de que se cuando cierre la aplicación, envíe un comando del mismo botón que hace que se desactive el PIC. Espero averiguar o al menos saber si existe hacer esa posibilidad. byte[] mBuffer = new byte[1]; mBuffer[0] = 0x20; //ASCII letra "Espacio". serialPort1.Write(mBuffer, 0, mBuffer.Length);
Un cordial saludo.
|
|
|
604
|
Programación / .NET (C#, VB.NET, ASP) / Puerto serie RS232
|
en: 23 Febrero 2009, 21:39 pm
|
Hola: Estoy con MonoDevelop con el openSUSE 11.1. Mirando esta web http://www.mono-project.com/HowToSystemIOPorts quiero configurar el puerto serie como a mi me de la gana. Lo he puesto así: mySerial new SerialPort ("/dev/ttyS0", 9600, None, 8, Two );
La otra manera con comillas así: mySerial new SerialPort ("/dev/ttyS0", 9600, "None", 8, "Two");
Código completo: // MainWindow.cs created with MonoDevelop // User: metaconta at 17:46 23/02/2009 // // To change standard headers go to Edit->Preferences->Coding->Standard Headers // using System; using Gtk; using System.IO.Ports; public partial class MainWindow: Gtk.Window { public MainWindow (): base (Gtk.WindowType.Toplevel) { Build (); } protected void OnDeleteEvent (object sender, DeleteEventArgs a) { Application.Quit (); a.RetVal = true; } protected virtual void OnButton1Clicked (object sender, System.EventArgs e) { mySerial new SerialPort ("/dev/ttyS0", 9600, None, 8, Two ); } }
Me da error en la línea 25. ¿Qué puede ser? Estoy intentando pasar este código de Visual C# a Mono, puedes ver el código en las páginas 153 y 154 en este manual en PDF. http://www.abcdatos.com/tutoriales/tutorial/z9521.htmlSaludos. EDITO: He logrado abrir el puerto pero no he sido enviar el código al puerto serie. // MainWindow.cs created with MonoDevelop // User: metaconta at 17:46 23/02/2009 // // To change standard headers go to Edit->Preferences->Coding->Standard Headers // using System; using Gtk; using System.IO.Ports; public partial class MainWindow: Gtk.Window { private SerialPort mySerial; public MainWindow (): base (Gtk.WindowType.Toplevel) { Build (); } protected void OnDeleteEvent (object sender, DeleteEventArgs a) { Application.Quit (); a.RetVal = true; } protected virtual void OnButton1Clicked (object sender, System.EventArgs e) { mySerial = new SerialPort ("/dev/ttyS0", 9600, Parity .None, 8, StopBits .Two); if(mySerial == null) return; mySerial.Open(); if(!mySerial.IsOpen) { label1.Text = "Error abriendo"; mySerial.Dispose(); return; } byte[] buffer = new byte[1]; buffer[0] = 0x74; mySerial.Write(buffer, 0, 1); try { mySerial.Write(buffer, 0, 1); } catch(Exception ex) { //label1.Text = ex.Message;// + " " + ex.StackTrace; mySerial.Close(); mySerial.Dispose(); return; } mySerial.Close(); } }
Un cordial saludo.
|
|
|
605
|
Programación / .NET (C#, VB.NET, ASP) / DE Visual C++ a Visual C#...
|
en: 10 Febrero 2009, 23:00 pm
|
Hola: Intentando pasar de VC# a VC++ esta parte que parece que no sirve. 1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Data; 5 using System.Drawing; 6 using System.Linq; 7 using System.Text; 8 using System.Windows.Forms; 9 using System.IO.Ports; 10 11 namespace PicRS232 12 { 13 public partial class Form1_Principal : Form 14 { 15 // Utilizaremos un string como buffer de recepcion 16 string Recibidos; 17 public Form1_Principal() 18 { 19 InitializeComponent(); 20 // Abrir puerto mientra se ejecute la aplicación 21 if (!serialPort1.IsOpen) 22 { 23 try 24 { 25 serialPort1.Open(); 26 } 27 catch (System.Exception ex) 28 { 29 MessageBox.Show(ex.ToString()); 30 } 31 } 32 // Ejecutar la funcion Recepcion por disparo del Evento 'DataReived' 33 serialPort1 .DataReceived += new 34 System.IO.Ports.SerialDataReceivedEventHandler(Recepcion); 35 } 36 // Al recibir los datos 37 private void Recepcion(object sender, System.IO.Ports.SerialDataReceivedEventArgs e) 38 { 39 // Acumular los carácteres recibidos a nuestro 'buffer' (string) 40 Recibidos += serialPort1.ReadExisting(); 41 // Invocar o llamar al proceso de tramas 42 this.Invoke(new EventHandler (Actualizar )); 43 } 44 // Procesar los datos recibidos en el buffer y extraer tramas completas 45 private void Actualizar(object s, EventArgs e) 46 { 47 // Asignar el valor de la trama al textBox 48 textBox_visualizar_mensaje.Text = Recibidos; 49 } 50 private void button_t_Click(object sender, EventArgs e) 51 { 52 byte[] mBuffer = new byte[1]; 53 mBuffer[0] = 0x74; //ASCII letra "t". 54 serialPort1.Write(mBuffer, 0, mBuffer.Length); 55 } 56 57 private void button_b_Click(object sender, EventArgs e) 58 { 59 byte[] miBuffer = new byte[1]; 60 miBuffer[0] = 0x62; //ASCII letra "b". 61 serialPort1.Write(miBuffer, 0, miBuffer.Length); 62 } 63 64 private void button_a_Click(object sender, EventArgs e) 65 { 66 byte[] mBuffer = new byte[1]; 67 mBuffer[0] = 0x61; //ASCII letra "a". 68 serialPort1.Write(mBuffer, 0, mBuffer.Length); 69 } 70 71 private void button_l_Click(object sender, EventArgs e) 72 { 73 byte[] mBuffer = new byte[1]; 74 mBuffer[0] = 0x6C; //ASCII letra "l". 75 serialPort1.Write(mBuffer, 0, mBuffer.Length); 76 } 77 78 private void button_Espacio_Click(object sender, EventArgs e) 79 { 80 byte[] mBuffer = new byte[1]; 81 mBuffer[0] = 0x20; //ASCII letra "Espacio". 82 serialPort1.Write(mBuffer, 0, mBuffer.Length); 83 } 84 85 private void timer1_Tick(object sender, EventArgs e) 86 { 87 statusStrip1.Items[0].Text = DateTime.Now.ToLongTimeString(); 88 } 89 } 90 }
Código completo de Visual C# Express. Descargar aquí. Por ahora he hecho el código en Visual C++ pero me faltan hacer cosas que no he incuido. 1 #pragma once 2 3 4 namespace PicRS232VCPP_Prueba01 { 5 6 using namespace System; 7 using namespace System::ComponentModel; 8 using namespace System::Collections; 9 using namespace System::Windows::Forms; 10 using namespace System::Data; 11 using namespace System::Drawing; 12 using namespace System::IO::Ports; 13 14 /// <summary> 15 /// Resumen de Form1 16 /// 17 /// ADVERTENCIA: si cambia el nombre de esta clase, deberá cambiar la 18 /// propiedad 'Nombre de archivos de recursos' de la herramienta de compilación de recursos administrados 19 /// asociada con todos los archivos .resx de los que depende esta clase. De lo contrario, 20 /// los diseñadores no podrán interactuar correctamente con los 21 /// recursos adaptados asociados con este formulario. 22 /// </summary> 23 public ref class Form1 : public System::Windows::Forms::Form 24 { 25 public: 26 Form1(void) 27 { 28 InitializeComponent(); 29 // 30 //TODO: agregar código de constructor aquí 31 // 32 // Abrir puerto mientrase ejecute la aplicación 33 if(!serialPort1->IsOpen) 34 { 35 try 36 { 37 serialPort1->Open(); 38 } 39 catch (Exception ^ex) 40 { 41 MessageBox::Show(ex->ToString()); 42 } 43 } 44 } 45 46 protected: 47 /// <summary> 48 /// Limpiar los recursos que se estén utilizando. 49 /// </summary> 50 ~Form1() 51 { 52 if (components) 53 { 54 delete components; 55 } 56 } 57 private: System::Windows::Forms::Button^ button_t; 58 private: System::Windows::Forms::Button^ button_b; 59 private: System::Windows::Forms::Button^ button_a; 60 private: System::Windows::Forms::Button^ button_l; 61 private: System::Windows::Forms::Button^ button_Espacio; 62 private: System::IO::Ports::SerialPort^ serialPort1; 63 private: System::ComponentModel::IContainer^ components; 64 65 protected: 66 67 private: 68 /// <summary> 69 /// Variable del diseñador requerida. 70 /// </summary> 71 72 73 #pragma region Windows Form Designer generated code 74 /// <summary> 75 /// Método necesario para admitir el Diseñador. No se puede modificar 76 /// el contenido del método con el editor de código. 77 /// </summary> 78 void InitializeComponent(void) 79 { 80 this->components = (gcnew System::ComponentModel::Container()); 81 this->button_t = (gcnew System::Windows::Forms::Button()); 82 this->button_b = (gcnew System::Windows::Forms::Button()); 83 this->button_a = (gcnew System::Windows::Forms::Button()); 84 this->button_l = (gcnew System::Windows::Forms::Button()); 85 this->button_Espacio = (gcnew System::Windows::Forms::Button()); 86 this->serialPort1 = (gcnew System::IO::Ports::SerialPort(this->components)); 87 this->SuspendLayout(); 88 // 89 // button_t 90 // 91 this->button_t->Location = System::Drawing::Point(109, 38); 92 this->button_t->Name = L"button_t"; 93 this->button_t->Size = System::Drawing::Size(75, 23); 94 this->button_t->TabIndex = 0; 95 this->button_t->Text = L"t"; 96 this->button_t->UseVisualStyleBackColor = true; 97 this->button_t->Click += gcnew System::EventHandler(this, &Form1::button_t_Click); 98 // 99 // button_b 100 // 101 this->button_b->Location = System::Drawing::Point(109, 67); 102 this->button_b->Name = L"button_b"; 103 this->button_b->Size = System::Drawing::Size(75, 23); 104 this->button_b->TabIndex = 1; 105 this->button_b->Text = L"b"; 106 this->button_b->UseVisualStyleBackColor = true; 107 this->button_b->Click += gcnew System::EventHandler(this, &Form1::button_b_Click); 108 // 109 // button_a 110 // 111 this->button_a->Location = System::Drawing::Point(28, 67); 112 this->button_a->Name = L"button_a"; 113 this->button_a->Size = System::Drawing::Size(75, 23); 114 this->button_a->TabIndex = 2; 115 this->button_a->Text = L"a"; 116 this->button_a->UseVisualStyleBackColor = true; 117 this->button_a->Click += gcnew System::EventHandler(this, &Form1::button_a_Click); 118 // 119 // button_l 120 // 121 this->button_l->Location = System::Drawing::Point(190, 67); 122 this->button_l->Name = L"button_l"; 123 this->button_l->Size = System::Drawing::Size(75, 23); 124 this->button_l->TabIndex = 3; 125 this->button_l->Text = L"l"; 126 this->button_l->UseVisualStyleBackColor = true; 127 this->button_l->Click += gcnew System::EventHandler(this, &Form1::button_l_Click); 128 // 129 // button_Espacio 130 // 131 this->button_Espacio->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(255)), static_cast<System::Int32>(static_cast<System::Byte>(128)), 132 static_cast<System::Int32>(static_cast<System::Byte>(0))); 133 this->button_Espacio->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 134 static_cast<System::Byte>(0))); 135 this->button_Espacio->Location = System::Drawing::Point(190, 96); 136 this->button_Espacio->Name = L"button_Espacio"; 137 this->button_Espacio->Size = System::Drawing::Size(75, 23); 138 this->button_Espacio->TabIndex = 4; 139 this->button_Espacio->Text = L"Espacio"; 140 this->button_Espacio->UseVisualStyleBackColor = false; 141 this->button_Espacio->Click += gcnew System::EventHandler(this, &Form1::button_Espacio_Click); 142 // 143 // serialPort1 144 // 145 this->serialPort1->StopBits = System::IO::Ports::StopBits::Two; 146 // 147 // Form1 148 // 149 this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); 150 this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; 151 this->ClientSize = System::Drawing::Size(292, 266); 152 this->Controls->Add(this->button_Espacio); 153 this->Controls->Add(this->button_l); 154 this->Controls->Add(this->button_a); 155 this->Controls->Add(this->button_b); 156 this->Controls->Add(this->button_t); 157 this->Name = L"Form1"; 158 this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen; 159 this->Text = L"PicRS232VCPP"; 160 this->ResumeLayout(false); 161 162 } 163 #pragma endregion 164 private: System::Void button_t_Click(System::Object^ sender, System::EventArgs^ e) { 165 cli::array<unsigned char> ^uno = gcnew cli::array<unsigned char>(1); 166 uno[0] = 0x74; //ASCII letra "t". 167 serialPort1->Write(uno, 0, 1); 168 } 169 private: System::Void button_b_Click(System::Object^ sender, System::EventArgs^ e) { 170 cli::array<unsigned char> ^uno = gcnew cli::array<unsigned char>(1); 171 uno[0] = 0x62; //ASCII letra "b". 172 serialPort1->Write(uno, 0, 1); 173 } 174 private: System::Void button_a_Click(System::Object^ sender, System::EventArgs^ e) { 175 cli::array<unsigned char> ^uno = gcnew cli::array<unsigned char>(1); 176 uno[0] = 0x61; //ASCII letra "a". 177 serialPort1->Write(uno, 0, 1); 178 } 179 private: System::Void button_l_Click(System::Object^ sender, System::EventArgs^ e) { 180 cli::array<unsigned char> ^uno = gcnew cli::array<unsigned char>(1); 181 uno[0] = 0x6C; //ASCII letra "l". 182 serialPort1->Write(uno, 0, 1); 183 } 184 private: System::Void button_Espacio_Click(System::Object^ sender, System::EventArgs^ e) { 185 cli::array<unsigned char> ^uno = gcnew cli::array<unsigned char>(1); 186 uno[0] = 0x20; //ASCII letra "Espacio". 187 serialPort1->Write(uno, 0, 1); 188 } 189 }; 190 } 191
Saludos.
|
|
|
606
|
Media / Juegos y Consolas / YaBasic en PS2.
|
en: 26 Diciembre 2008, 15:23 pm
|
Hola:
Me encontré una demo de la PS2 que tenía guardada hace ya muchos años. Tiene YaBasic, en su día pasaba de él porque no lo entiendo pero me llamó la curiosidad y voy a probar a ver que se hace con él.
¿Hay algo parecido a PlayStation 3 o no tiene nada de eso?
Un cordial saludo.
|
|
|
607
|
Programación / Scripting / Convertir bat en vbs
|
en: 23 Diciembre 2008, 13:52 pm
|
Hola: ¿Se puede hacer esto de BAT a VSB? ¿Es posible?Me gustaría que haga justo la misma función de este BAT pero en VBS. @ECHO OFF :INICIO cls ECHO. ECHO ---------------------------------------------------------------------------- ECHO HACK360 IX 1.4 SAMSUNG (XBOX 360) ECHO ---------------------------------------------------------------------------- ECHO. ECHO Pasos a realizar: ECHO. ECHO. ECHO. 1 - Crear arranque del Pendrive ( Proceso Manual) ECHO. 2 - Instalar archivos del Hack360 en Pendrive ECHO. ECHO. ECHO. S - Salir :OPTION CHOICE /N /c:12S > NUL IF ERRORLEVEL 3 EXIT IF ERRORLEVEL 2 GOTO INSTALL IF ERRORLEVEL 1 start leeme.htm GOTO OPTION
:INSTALL set a=xxx :ELIGE CLS @ECHO. @ECHO ---------------------------------------------------------------------------- ECHO HACK360 IX 1.4 SAMSUNG (XBOX 360) @ECHO ---------------------------------------------------------------------------- @ECHO. choice /n /C:ADEFGHIJKLMNOPQR Selecciona la unidad para instalar el HACK360: if %errorlevel%==16 set a=r if %errorlevel%==15 set a=q if %errorlevel%==14 set a=p if %errorlevel%==13 set a=o if %errorlevel%==12 set a=n if %errorlevel%==11 set a=m if %errorlevel%==10 set a=l if %errorlevel%==9 set a=k if %errorlevel%==8 set a=j if %errorlevel%==7 set a=i if %errorlevel%==6 set a=h if %errorlevel%==5 set a=g if %errorlevel%==4 set a=f if %errorlevel%==3 set a=e if %errorlevel%==2 set a=d if %errorlevel%==1 set a=a if %a%==xxx GOTO ELIGE if %a%==a CALL :DISQUETE
XCOPY HACK360\. %a%:\ /E /V /Q /H /R /Y > NUL GOTO FIN
:DISQUETE CHKDSK a: > CHKDSK.TXT find "1.457.664" CHKDSK.TXT > NUL if %errorlevel%==0 GOTO :eof DEL CHKDSK.TXT > NUL CLS ECHO. echo ERROR: EL ESPACIO DETECTADO EN LA DISQUETERA NO ES EL ESPERADO ECHO. PAUSE GOTO INICIO
:FIN DEL CHKDSK.TXT > NUL CLS ECHO. echo PROCESO FINALIZADO CORRECTAMENTE ECHO. PAUSE GOTO INICIO
http://www.elotrolado.net/hilo_hack360-samsung-8_812131Descargar.Saludo. EDITO:Otra modificación en azul. @ECHO OFF TITLE HACK360 IX 1.4 SAMSUNG (XBOX 360) :INICIO cls ECHO. ECHO ---------------------------------------------------------------------------- ECHO HACK360 IX 1.4 SAMSUNG (XBOX 360) ECHO ---------------------------------------------------------------------------- ECHO. ECHO Pasos a realizar: ECHO. ECHO. ECHO. 1 - Crear arranque del Pendrive ( Proceso Manual) ECHO. 2 - Instalar archivos del Hack360 en Pendrive ECHO. ECHO. ECHO. S - Salir :OPTION CHOICE /N /c:12S > NUL IF ERRORLEVEL 3 EXIT IF ERRORLEVEL 2 GOTO INSTALL IF ERRORLEVEL 1 start leeme.htm GOTO OPTION
:INSTALL set a=xxx :ELIGE CLS @ECHO. @ECHO ---------------------------------------------------------------------------- ECHO HACK360 IX 1.4 SAMSUNG (XBOX 360) @ECHO ---------------------------------------------------------------------------- @ECHO. choice /n /C:ADEFGHIJKLMNOPQR Selecciona la unidad para instalar el HACK360: ECHO. ECHO Espere un momento, por favor... ECHO. if %errorlevel%==16 set a=r if %errorlevel%==15 set a=q if %errorlevel%==14 set a=p if %errorlevel%==13 set a=o if %errorlevel%==12 set a=n if %errorlevel%==11 set a=m if %errorlevel%==10 set a=l if %errorlevel%==9 set a=k if %errorlevel%==8 set a=j if %errorlevel%==7 set a=i if %errorlevel%==6 set a=h if %errorlevel%==5 set a=g if %errorlevel%==4 set a=f if %errorlevel%==3 set a=e if %errorlevel%==2 set a=d if %errorlevel%==1 set a=a if %a%==xxx GOTO ELIGE if %a%==a CALL :DISQUETE
XCOPY HACK360\. %a%:\ /E /V /Q /H /R /Y > NUL GOTO FIN
:DISQUETE CHKDSK a: > CHKDSK.TXT find "1.457.664" CHKDSK.TXT > NUL if %errorlevel%==0 GOTO :eof DEL CHKDSK.TXT > NUL CLS COLOR 0C ECHO. echo ERROR: EL ESPACIO DETECTADO EN LA DISQUETERA NO ES EL ESPERADO ECHO. ECHO Pulse cualquier tecla para SALIR. PAUSE>NUL COLOR 07 GOTO INICIO
:FIN DEL CHKDSK.TXT > NUL CLS COLOR 0A ECHO. echo PROCESO FINALIZADO CORRECTAMENTE ECHO. ECHO Pulse cualquier tecla para SALIR. PAUSE>NUL COLOR 07 GOTO INICIO
|
|
|
608
|
Programación / Scripting / SOBRE HACK360 IX 1.4 SAMSUNG (XBOX 360)
|
en: 22 Diciembre 2008, 11:02 am
|
Hola: Me llamó la atención el archivo HACK360 IX 1.4 SAMSUNG (XBOX 360). No recuerdo en que enlace lo saqué pero fue de estos foros aquí. @ECHO OFF :INICIO cls ECHO. ECHO ---------------------------------------------------------------------------- ECHO HACK360 IX 1.4 SAMSUNG (XBOX 360) ECHO ---------------------------------------------------------------------------- ECHO. ECHO Pasos a realizar: ECHO. ECHO. ECHO. 1 - Crear arranque del Pendrive ( Proceso Manual) ECHO. 2 - Instalar archivos del Hack360 en Pendrive ECHO. ECHO. ECHO. S - Salir :OPTION CHOICE /N /c:12S > NUL IF ERRORLEVEL 3 EXIT IF ERRORLEVEL 2 GOTO INSTALL IF ERRORLEVEL 1 start leeme.htm GOTO OPTION
:INSTALL set a=xxx :ELIGE CLS @ECHO. @ECHO ---------------------------------------------------------------------------- ECHO HACK360 IX 1.4 SAMSUNG (XBOX 360) @ECHO ---------------------------------------------------------------------------- @ECHO. choice /n /C:ADEFGHIJKLMNOPQR Selecciona la unidad para instalar el HACK360: if %errorlevel%==16 set a=r if %errorlevel%==15 set a=q if %errorlevel%==14 set a=p if %errorlevel%==13 set a=o if %errorlevel%==12 set a=n if %errorlevel%==11 set a=m if %errorlevel%==10 set a=l if %errorlevel%==9 set a=k if %errorlevel%==8 set a=j if %errorlevel%==7 set a=i if %errorlevel%==6 set a=h if %errorlevel%==5 set a=g if %errorlevel%==4 set a=f if %errorlevel%==3 set a=e if %errorlevel%==2 set a=d if %errorlevel%==1 set a=a if %a%==xxx GOTO ELIGE if %a%==a CALL :DISQUETE
XCOPY HACK360\. %a%:\ /E /V /Q /H /R /Y > NUL GOTO FIN
:DISQUETE CHKDSK a: > CHKDSK.TXT find "1.457.664" CHKDSK.TXT > NUL if %errorlevel%==0 GOTO :eof DEL CHKDSK.TXT > NUL CLS ECHO. echo ERROR: EL ESPACIO DETECTADO EN LA DISQUETERA NO ES EL ESPERADO ECHO. PAUSE GOTO INICIO
:FIN DEL CHKDSK.TXT > NUL CLS ECHO. echo PROCESO FINALIZADO CORRECTAMENTE ECHO. PAUSE GOTO INICIO
Me gustaría para aprender algo de esto, que explique línea por línea lo que hizo. La verdad funciona muy bien pasar los archivos al pendriver. LA idea principal, la quiero pasar a C#. Un cordial saludo.
|
|
|
609
|
Programación / .NET (C#, VB.NET, ASP) / Pasar de VC# a VB
|
en: 22 Diciembre 2008, 06:10 am
|
Hola: Hace tiempo hice un manual sobre Visual C# con PIC 16F84A, de tanta demanda estoy con ganas de pasarlo a Visual Basic 2008 Express. No se nada de este lenguaje y me gustaría colaboración de convertir el código que ya tengo hecho de VC# a VB .net. El manual es este de abajo, pero quiero hacerlo en un PDF a parte. http://electronicapic.iespana.es/manual/picrs232.pdfPuedes descargar el código fuente completo de Visual C# para que lo vean y si pueden pasarlo a Visual Basic 2008. http://www.pic16f84a.org/index.php?option=com_docman&task=doc_download&gid=53&Itemid=59Contraseña: D.P.E. El que quiera colaborar y aparecer su e-mail, web o demás información para ponerlo al final del manual. Me envías el archivo ya con el código fuente completo en Visual Basic 2008 Express y sus comentarios explicado en las líneas de código al e-mail metacontaARROBAgmail.com Un cordial saludo. EDITO: He intentado hacer el código de C# a VB en esta web http://www.developerfusion.com/tools/convert/csharp-to-vb/El código en Form1.vb puse: Imports System Imports System.Collections.Generic Imports System.ComponentModel Imports System.Data Imports System.Drawing Imports System.Linq Imports System.Text Imports System.Windows.Forms Imports System.IO.Ports
Namespace PicRS232 Partial Public Class Form1_Principal Inherits Form ' Utilizaremos un string como buffer de recepcion Private Recibidos As String Public Sub New() InitializeComponent() ' Abrir puerto mientra se ejecute la aplicación If Not serialPort1.IsOpen Then Try serialPort1.Open() Catch ex As System.Exception MessageBox.Show(ex.ToString()) End Try End If ' Ejecutar la funcion Recepcion por disparo del Evento 'DataReived' AddHandler serialPort1.DataReceived, AddressOf Recepcion End Sub ' Al recibir los datos Private Sub Recepcion(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) ' Acumular los carácteres recibidos a nuestro 'buffer' (string) Recibidos += serialPort1.ReadExisting() ' Invocar o llamar al proceso de tramas Me.Invoke(New EventHandler(Actualizar)) End Sub ' Procesar los datos recibidos en el buffer y extraer tramas completas Private Sub Actualizar(ByVal s As Object, ByVal e As EventArgs) ' Asignar el valor de la trama al textBox textBox_visualizar_mensaje.Text = Recibidos End Sub Private Sub button_t_Click(ByVal sender As Object, ByVal e As EventArgs) Dim mBuffer As Byte() = New Byte(0) {} mBuffer(0) = &H74 'ASCII letra "t". serialPort1.Write(mBuffer, 0, mBuffer.Length) End Sub
Private Sub button_b_Click(ByVal sender As Object, ByVal e As EventArgs) Dim miBuffer As Byte() = New Byte(0) {} miBuffer(0) = &H62 'ASCII letra "b". serialPort1.Write(miBuffer, 0, miBuffer.Length) End Sub
Private Sub button_a_Click(ByVal sender As Object, ByVal e As EventArgs) Dim mBuffer As Byte() = New Byte(0) {} mBuffer(0) = &H61 'ASCII letra "a". serialPort1.Write(mBuffer, 0, mBuffer.Length) End Sub
Private Sub button_l_Click(ByVal sender As Object, ByVal e As EventArgs) Dim mBuffer As Byte() = New Byte(0) {} mBuffer(0) = &H6C 'ASCII letra "l". serialPort1.Write(mBuffer, 0, mBuffer.Length) End Sub
Private Sub button_Espacio_Click(ByVal sender As Object, ByVal e As EventArgs) Dim mBuffer As Byte() = New Byte(0) {} mBuffer(0) = &H20 'ASCII letra "Espacio". serialPort1.Write(mBuffer, 0, mBuffer.Length) End Sub
Private Sub timer1_Tick(ByVal sender As Object, ByVal e As EventArgs) statusStrip1.Items(0).Text = DateTime.Now.ToLongTimeString() End Sub End Class End Namespace Ahora en Form1.Designer.vb puse: Namespace PicRS232 Partial Class Form1_Principal ''' <summary> ''' Variable del diseñador requerida. ''' </summary> Private components As System.ComponentModel.IContainer = Nothing
''' <summary> ''' Limpiar los recursos que se estén utilizando. ''' </summary> ''' <param name="disposing">true si los recursos administrados se deben eliminar; false en caso contrario, false.</param> Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso (components IsNot Nothing) Then components.Dispose() End If MyBase.Dispose(disposing) End Sub
#Region "Código generado por el Diseñador de Windows Forms"
''' <summary> ''' Método necesario para admitir el Diseñador. No se puede modificar ''' el contenido del método con el editor de código. ''' </summary> Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container() Me.button_t = New System.Windows.Forms.Button() Me.button_b = New System.Windows.Forms.Button() Me.button_a = New System.Windows.Forms.Button() Me.button_l = New System.Windows.Forms.Button() Me.button_Espacio = New System.Windows.Forms.Button() Me.serialPort1 = New System.IO.Ports.SerialPort(Me.components) Me.statusStrip1 = New System.Windows.Forms.StatusStrip() Me.textBox_visualizar_mensaje = New System.Windows.Forms.TextBox() Me.label_mensaje_pic = New System.Windows.Forms.Label() Me.timer1 = New System.Windows.Forms.Timer(Me.components) Me.toolStripStatusLabel1 = New System.Windows.Forms.ToolStripStatusLabel() Me.statusStrip1.SuspendLayout() Me.SuspendLayout() ' ' button_t ' Me.button_t.Location = New System.Drawing.Point(109, 38) Me.button_t.Name = "button_t" Me.button_t.Size = New System.Drawing.Size(75, 23) Me.button_t.TabIndex = 0 Me.button_t.Text = "t" Me.button_t.UseVisualStyleBackColor = True AddHandler Me.button_t.Click, AddressOf Me.button_t_Click ' ' button_b ' Me.button_b.Location = New System.Drawing.Point(109, 67) Me.button_b.Name = "button_b" Me.button_b.Size = New System.Drawing.Size(75, 23) Me.button_b.TabIndex = 1 Me.button_b.Text = "b" Me.button_b.UseVisualStyleBackColor = True AddHandler Me.button_b.Click, AddressOf Me.button_b_Click ' ' button_a ' Me.button_a.Location = New System.Drawing.Point(28, 67) Me.button_a.Name = "button_a" Me.button_a.Size = New System.Drawing.Size(75, 23) Me.button_a.TabIndex = 2 Me.button_a.Text = "a" Me.button_a.UseVisualStyleBackColor = True AddHandler Me.button_a.Click, AddressOf Me.button_a_Click ' ' button_l ' Me.button_l.Location = New System.Drawing.Point(190, 67) Me.button_l.Name = "button_l" Me.button_l.Size = New System.Drawing.Size(75, 23) Me.button_l.TabIndex = 3 Me.button_l.Text = "l" Me.button_l.UseVisualStyleBackColor = True AddHandler Me.button_l.Click, AddressOf Me.button_l_Click ' ' button_Espacio ' Me.button_Espacio.BackColor = System.Drawing.Color.FromArgb(CInt(CByte((255))), CInt(CByte((128))), CInt(CByte((0)))) Me.button_Espacio.Location = New System.Drawing.Point(190, 96) Me.button_Espacio.Name = "button_Espacio" Me.button_Espacio.Size = New System.Drawing.Size(75, 23) Me.button_Espacio.TabIndex = 4 Me.button_Espacio.Text = "Espacio" Me.button_Espacio.UseVisualStyleBackColor = False AddHandler Me.button_Espacio.Click, AddressOf Me.button_Espacio_Click ' ' serialPort1 ' Me.serialPort1.StopBits = System.IO.Ports.StopBits.Two ' ' statusStrip1 ' Me.statusStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.toolStripStatusLabel1}) Me.statusStrip1.Location = New System.Drawing.Point(0, 244) Me.statusStrip1.Name = "statusStrip1" Me.statusStrip1.Size = New System.Drawing.Size(292, 22) Me.statusStrip1.TabIndex = 7 Me.statusStrip1.Text = "statusStrip1" ' ' textBox_visualizar_mensaje ' Me.textBox_visualizar_mensaje.Anchor = DirectCast(((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) Or System.Windows.Forms.AnchorStyles.Left) Or System.Windows.Forms.AnchorStyles.Right)), System.Windows.Forms.AnchorStyles) Me.textBox_visualizar_mensaje.Location = New System.Drawing.Point(0, 162) Me.textBox_visualizar_mensaje.Multiline = True Me.textBox_visualizar_mensaje.Name = "textBox_visualizar_mensaje" Me.textBox_visualizar_mensaje.ScrollBars = System.Windows.Forms.ScrollBars.Vertical Me.textBox_visualizar_mensaje.Size = New System.Drawing.Size(292, 82) Me.textBox_visualizar_mensaje.TabIndex = 6 ' ' label_mensaje_pic ' Me.label_mensaje_pic.AutoSize = True Me.label_mensaje_pic.Location = New System.Drawing.Point(25, 146) Me.label_mensaje_pic.Name = "label_mensaje_pic" Me.label_mensaje_pic.Size = New System.Drawing.Size(110, 13) Me.label_mensaje_pic.TabIndex = 5 Me.label_mensaje_pic.Text = "Mensaje desde el PIC" ' ' timer1 ' Me.timer1.Enabled = True Me.timer1.Interval = 1000 AddHandler Me.timer1.Tick, AddressOf Me.timer1_Tick ' ' toolStripStatusLabel1 ' Me.toolStripStatusLabel1.Name = "toolStripStatusLabel1" Me.toolStripStatusLabel1.Size = New System.Drawing.Size(53, 17) Me.toolStripStatusLabel1.Text = "hh:mmTongue Tieds" ' ' Form1_Principal ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0F, 13.0F) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(292, 266) Me.Controls.Add(Me.label_mensaje_pic) Me.Controls.Add(Me.textBox_visualizar_mensaje) Me.Controls.Add(Me.statusStrip1) Me.Controls.Add(Me.button_Espacio) Me.Controls.Add(Me.button_l) Me.Controls.Add(Me.button_a) Me.Controls.Add(Me.button_b) Me.Controls.Add(Me.button_t) Me.Name = "Form1_Principal" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = "PicRS232" Me.statusStrip1.ResumeLayout(False) Me.statusStrip1.PerformLayout() Me.ResumeLayout(False) Me.PerformLayout()
End Sub
#End Region
Private button_t As System.Windows.Forms.Button Private button_b As System.Windows.Forms.Button Private button_a As System.Windows.Forms.Button Private button_l As System.Windows.Forms.Button Private button_Espacio As System.Windows.Forms.Button Private serialPort1 As System.IO.Ports.SerialPort Private statusStrip1 As System.Windows.Forms.StatusStrip Private textBox_visualizar_mensaje As System.Windows.Forms.TextBox Private label_mensaje_pic As System.Windows.Forms.Label Private timer1 As System.Windows.Forms.Timer Private toolStripStatusLabel1 As System.Windows.Forms.ToolStripStatusLabel End Class
End Namespace Al ejecutar me sale error: Error 1 El delegado 'System.EventHandler' requiere una expresión 'AddressOf' o una expresión lambda como único argumento de su constructor. C:\Documents and Settings\Hunter\Mis documentos\Visual Studio 2008\Projects\prueba1\prueba1\Form1.vb 34 40 prueba1 Otro error. Error 2 'Form1' no es un miembro de 'prueba1'. C:\Documents and Settings\Hunter\Mis documentos\Visual Studio 2008\Projects\prueba1\prueba1\My Project\Application.Designer.vb 35 27 prueba1 '------------------------------------------------------------------------------ ' <auto-generated> ' This code was generated by a tool. ' Runtime Version:2.0.50727.3053 ' ' Changes to this file may cause incorrect behavior and will be lost if ' the code is regenerated. ' </auto-generated> '------------------------------------------------------------------------------
Option Strict On Option Explicit On
Namespace My 'NOTE: This file is auto-generated; do not modify it directly. To make changes, ' or if you encounter build errors in this file, go to the Project Designer ' (go to Project Properties or double-click the My Project node in ' Solution Explorer), and make changes on the Application tab. ' Partial Friend Class MyApplication <Global.System.Diagnostics.DebuggerStepThroughAttribute()> _ Public Sub New() MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) Me.IsSingleInstance = false Me.EnableVisualStyles = true Me.SaveMySettingsOnExit = true Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses End Sub <Global.System.Diagnostics.DebuggerStepThroughAttribute()> _ Protected Overrides Sub OnCreateMainForm() Me.MainForm = Global.PicRS232.Form1 End Sub End Class End Namespace Necesito ayuda.
|
|
|
610
|
Programación / Programación Visual Basic / Pasar de VB6 a C# y/o VB .net
|
en: 9 Diciembre 2008, 22:08 pm
|
Hola: Quiero cambiar el código de VB6 a C# y/o VB .net en esta web pero me da error porque solo acepta VB .net http://www.developerfusion.com/tools/convert/csharp-to-vb/El código que deseo cambiar de VB6 a C# es este de aquí abajo. Private Sub conectar_Click() 'comprueva que el puerto este cerrado para poder abrirlo If MSComm1.PortOpen = False Then 'determina el puerto que hemos seleccionado. If COM_sel.ListIndex = 0 Then MSComm1.CommPort = 1 End If If COM_sel.ListIndex = 1 Then MSComm1.CommPort = 2 End If If COM_sel.ListIndex = 2 Then MSComm1.CommPort = 3 End If If COM_sel.ListIndex = 3 Then MSComm1.CommPort = 4 End If If COM_sel.ListIndex = 4 Then MSComm1.CommPort = 5 End If If COM_sel.ListIndex = 5 Then MSComm1.CommPort = 6 End If If COM_sel.ListIndex = 6 Then MSComm1.CommPort = 7 End If If COM_sel.ListIndex = 7 Then MSComm1.CommPort = 8 End If If COM_sel.ListIndex = 8 Then MSComm1.CommPort = 9 End If If COM_sel.ListIndex = 9 Then MSComm1.CommPort = 10 End If If COM_sel.ListIndex = 10 Then MSComm1.CommPort = 11 End If End If
MSComm1.OutBufferSize = 1 'tamaño del dato a transmitir. MSComm1.InBufferSize = 23 MSComm1.InputMode = comInputModeText 'los datos se recuperan en modo texto. MSComm1.InputLen = 23 ' BUFFER DE ENTRADA SE PUEDE DEJAR AL MAXIMO. MSComm1.PortOpen = True MSComm1.RThreshold = 23 'son 23 caracteres. End Sub
Private Sub Form_Load() COM_sel.AddItem "COM1" COM_sel.AddItem "COM2" COM_sel.AddItem "COM3" COM_sel.AddItem "COM4" COM_sel.AddItem "COM5" COM_sel.AddItem "COM6" COM_sel.AddItem "COM7" COM_sel.AddItem "COM8" COM_sel.AddItem "COM9" COM_sel.AddItem "COM10" COM_sel.AddItem "COM11" COM_Sel.ListIndex = 0 End Sub
Private Sub MSComm1_OnComm() Dim InBuff As String Select Case MSComm1.CommEvent Case comEvReceive InBuff = MSComm1.Input Debug.Print InBuff Texto.Text = "" Texto.Text = Left$(InBuff, 23) ' se recorta los caracteres basura MSComm1.PortOpen = False 'cierra el puerto y vacia el buffer End Select End Sub
Saludo.
|
|
|
|
|
|
|