
07/10/2010, 20:17
|
 | | | Fecha de Ingreso: octubre-2010 Ubicación: Culiacán, Sinaloa
Mensajes: 54
Antigüedad: 14 años, 4 meses Puntos: 5 | |
Respuesta: Visual Basic 2010, busco forma de separar términos Cita:
Iniciado por sergio701 No se mucho de Basic asi que seguramente hay formas mas faciles de hacerlo, pero que te mando el codigo, espero que te sirva.
Código vb:
Ver originalPublic Sub separar(ByVal exp As String) Dim varible1 = "" Dim operador = "" Dim varible2 = "" Dim igual = "" Dim resultado = "" Dim encontro As Boolean = False Dim i = 0 While exp.Substring(i, 1) <> "=" If encontro = False Then varible1 = varible1 + exp.Substring(i, 1) End If If exp.Substring(i, 1) = "+" Or exp.Substring(i, 1) = "-" Or exp.Substring(i, 1) = "/" Or exp.Substring(i, 1) = "*" Then operador = exp.Substring(i, 1) encontro = True End If If encontro = True Then varible2 = varible2 + exp.Substring(i, 1) End If i = i + 1 End While igual = "=" varible1 = varible1.Substring(0, varible1.Length - 1) varible2 = varible2.Substring(1, varible2.Length - 1) resultado = exp.Substring(varible1.Length + varible2.Length + 2, exp.Length - varible1.Length - varible2.Length - 2) TextBox2.Text = varible1 TextBox3.Text = operador TextBox4.Text = varible2 TextBox5.Text = igual TextBox6.Text = resultado End Sub
He entendido alguna parte del código, ahora me lo podrias explicar en caso de que fueran tres variables?. |