Tiro (Movimiento) Parabolico con Visual Basic (VB.NET)
Se trata de una pequeña aplicación para resolver problemas de Tiro (Movimiento) Parabolico.
Codigo:
Form1
Public Class Form1
Dim DESPLAZAMIENTOX As Single 'DISTANCIA RECORRIDA EN EL EJE X
Dim TIEMPO As Single ' TIEMPO TOMADO PARA LOS CALCULOS
Dim ARRAYX As New ArrayList ' DATOS DE X EN FUNCION DEL TIEMPO
Dim ARRAYY As New ArrayList ' DATOS DE Y EN FUNCION DEL TIEMPO
Dim CONTADOR As Integer = 0 ' CONTADOR DE PASO DE TIEMPO
Dim TIEMPO As Single ' TIEMPO TOMADO PARA LOS CALCULOS
Dim ARRAYX As New ArrayList ' DATOS DE X EN FUNCION DEL TIEMPO
Dim ARRAYY As New ArrayList ' DATOS DE Y EN FUNCION DEL TIEMPO
Dim CONTADOR As Integer = 0 ' CONTADOR DE PASO DE TIEMPO
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'HACE LOS CALCULOS Y PONE EN MARCHA EL TIMER
CALCULAR_TIEMPO_DESPLAZAMIENTOX()
Timer1.Interval = 100
Timer1.Enabled = True
End Sub
Public Sub CALCULAR_TIEMPO_DESPLAZAMIENTOX()
'LIMPIA LOS ARRAYS Y EL CONTADOR POR SI SE HACEN VARIOS CALCULOS SIN REINICIAR LA APLICACION
ARRAYX.Clear()
ARRAYY.Clear()
CONTADOR = 0
PictureBox1.Image = Nothing
Try
'TOMA DATOS
Dim ALTURA_INI As Single = CSng(TextBoxALT_INI.Text)
Dim ALTURA_FIN As Single = CSng(TextBoxALT_FIN.Text)
Dim VELOCIDAD_INI As Single = CSng(TextBoxVEL_INI.Text)
Dim ANGULO As Single = CSng(TextBoxANGULO.Text)
'HACE LOS CALCULOS Y PONE EN MARCHA EL TIMER
CALCULAR_TIEMPO_DESPLAZAMIENTOX()
Timer1.Interval = 100
Timer1.Enabled = True
End Sub
Public Sub CALCULAR_TIEMPO_DESPLAZAMIENTOX()
'LIMPIA LOS ARRAYS Y EL CONTADOR POR SI SE HACEN VARIOS CALCULOS SIN REINICIAR LA APLICACION
ARRAYX.Clear()
ARRAYY.Clear()
CONTADOR = 0
PictureBox1.Image = Nothing
Try
'TOMA DATOS
Dim ALTURA_INI As Single = CSng(TextBoxALT_INI.Text)
Dim ALTURA_FIN As Single = CSng(TextBoxALT_FIN.Text)
Dim VELOCIDAD_INI As Single = CSng(TextBoxVEL_INI.Text)
Dim ANGULO As Single = CSng(TextBoxANGULO.Text)
Dim GRAVEDAD As Single = CSng(TextBoxGRAVEDAD.Text)
'CONVERSION GRADOS A RADIANES
Dim RADIANES As Single = ANGULO * Math.PI / 180
Dim RADIANES As Single = ANGULO * Math.PI / 180
'DETERMINAMOS SENO Y COSENO DEL ANGULO
Dim SENO As Single = Math.Sin(RADIANES)
LabelSENO.Text = Math.Round(SENO, 3)
Dim COSENO As Single = Math.Cos(RADIANES)
LabelCOSENO.Text = Math.Round(COSENO, 3)
Dim SENO As Single = Math.Sin(RADIANES)
LabelSENO.Text = Math.Round(SENO, 3)
Dim COSENO As Single = Math.Cos(RADIANES)
LabelCOSENO.Text = Math.Round(COSENO, 3)
'DETERMINAMOS VECTORES VELOCIDAD INICIAL X E Y
Dim VECTORY As Single = VELOCIDAD_INI * SENO
Dim VECTORX As Single = VELOCIDAD_INI * COSENO
Dim VECTORY As Single = VELOCIDAD_INI * SENO
Dim VECTORX As Single = VELOCIDAD_INI * COSENO
'DETERMINAMOS LA DIFERENCIA DE ALTURAS
Dim DIFERENCIA_ALTURAS As Single = ALTURA_FIN - ALTURA_INI
'SI ANGULO ES MAYOR QUE CERO
If ANGULO > 0 Then
If ANGULO > 0 Then
'DETERMINAMOS LOS DOS POSIBLES TIEMPOS QUE SALEN DE LA ECUACION BICUADRADA APLICANDO (-B +-(B^2-4AC)^0,5)/2A YA QUE: 1/2 * g* t^2 - Voyt - Yo + Yf = 0
Dim TIEMPO1 As Single = (VECTORY + Math.Sqrt((VECTORY ^ 2) - (2 * GRAVEDAD * DIFERENCIA_ALTURAS))) / GRAVEDAD
Label6.Text = Math.Round(TIEMPO1, 2) & " seg"
Dim TIEMPO2 As Single = (VECTORY - Math.Sqrt((VECTORY ^ 2) - (2 * GRAVEDAD * DIFERENCIA_ALTURAS))) / GRAVEDAD
Label7.Text = Math.Round(TIEMPO2, 2) & " seg"
Dim TIEMPO1 As Single = (VECTORY + Math.Sqrt((VECTORY ^ 2) - (2 * GRAVEDAD * DIFERENCIA_ALTURAS))) / GRAVEDAD
Label6.Text = Math.Round(TIEMPO1, 2) & " seg"
Dim TIEMPO2 As Single = (VECTORY - Math.Sqrt((VECTORY ^ 2) - (2 * GRAVEDAD * DIFERENCIA_ALTURAS))) / GRAVEDAD
Label7.Text = Math.Round(TIEMPO2, 2) & " seg"
'TOMAREMOS EL TIEMPO EN FUNCION DE LA DIFERENCIA DE ALTURAS. LO NORMAL ES QUE LA ALTURA INICIAL SEA MAYOR O IGUAL A LA FINAL.
'If ALTURA_INI >= ALTURA_FIN Then
' TIEMPO = Math.Max(TIEMPO1, TIEMPO2)
'If ALTURA_INI >= ALTURA_FIN Then
' TIEMPO = Math.Max(TIEMPO1, TIEMPO2)
'Else
' TIEMPO = Math.Min(TIEMPO1, TIEMPO2)
'End If
TIEMPO = Math.Max(TIEMPO1, TIEMPO2)
LabelTIEMPO.Text = Math.Round(TIEMPO, 2) & " seg"
' TIEMPO = Math.Min(TIEMPO1, TIEMPO2)
'End If
TIEMPO = Math.Max(TIEMPO1, TIEMPO2)
LabelTIEMPO.Text = Math.Round(TIEMPO, 2) & " seg"
'EN CASO DE QUE EL ANGULO SEA CERO
ElseIf ANGULO = 0 Then
ElseIf ANGULO = 0 Then
'DETERMINAMOS LOS DOS POSIBLES TIEMPOS QUE SALEN DE LA ECUACION Yf=Yo-(g*t^2)/2 YA QUE EL VECTOR Y SERA IGUAL A 0 => t=+-(2*(Yo-Yf)/g)^0,5
Dim TIEMPO1 As Single = Math.Sqrt(2 * (ALTURA_INI - ALTURA_FIN) / GRAVEDAD)
Label6.Text = Math.Round(TIEMPO1, 2) & " seg"
Dim TIEMPO2 As Single = Math.Sqrt(2 * (ALTURA_INI - ALTURA_FIN) / GRAVEDAD) * -1
Label7.Text = Math.Round(TIEMPO2, 2) & " seg"
Dim TIEMPO1 As Single = Math.Sqrt(2 * (ALTURA_INI - ALTURA_FIN) / GRAVEDAD)
Label6.Text = Math.Round(TIEMPO1, 2) & " seg"
Dim TIEMPO2 As Single = Math.Sqrt(2 * (ALTURA_INI - ALTURA_FIN) / GRAVEDAD) * -1
Label7.Text = Math.Round(TIEMPO2, 2) & " seg"
'TOMAMOS EL TIEMPO MAYOR DE LOS DOS POSIBLES. EN LA MAYORIA DE LOS EJERCICIOS SERA EL UTIL. AUNQUE NO SIEMPRE
TIEMPO = Math.Max(TIEMPO1, TIEMPO2)
LabelTIEMPO.Text = Math.Round(TIEMPO, 2) & " seg"
TIEMPO = Math.Max(TIEMPO1, TIEMPO2)
LabelTIEMPO.Text = Math.Round(TIEMPO, 2) & " seg"
'EN CASO DE QUE EL ANGULO SEA NEGATIVO
Else
MsgBox("REVISA EL VALOR DEL ANGULO")
End If
Else
MsgBox("REVISA EL VALOR DEL ANGULO")
End If
'EL DESPLAZAMIENTO EN X ES IGUAL AL VECTORX POR EL TIEMPO
DESPLAZAMIENTOX = VECTORX * TIEMPO
LabelDESPLAZX.Text = Math.Round(DESPLAZAMIENTOX, 2) & " m"
DESPLAZAMIENTOX = VECTORX * TIEMPO
LabelDESPLAZX.Text = Math.Round(DESPLAZAMIENTOX, 2) & " m"
'CARGAMOS LOS ARRAYS DEL DESPLAZAMIENTO EN X E Y EN FUNCION DEL TIEMPO
For I = 0 To TIEMPO
ARRAYX.Add(VECTORX * I)
ARRAYY.Add(ALTURA_INI + (VECTORY * I) - ((GRAVEDAD / 2) * I ^ 2))
Next
For I = 0 To TIEMPO
ARRAYX.Add(VECTORX * I)
ARRAYY.Add(ALTURA_INI + (VECTORY * I) - ((GRAVEDAD / 2) * I ^ 2))
Next
' AÑADE EL RESTO DE LAS MEDIDAS EN CASO DE QUE EL TIEMPO SEA UN NUMERO DECIMAL
Dim RESTOX As Single = DESPLAZAMIENTOX - ARRAYX(Math.Truncate(TIEMPO))
If RESTOX > 0 Then
ARRAYX.Add(DESPLAZAMIENTOX)
ARRAYY.Add(ALTURA_FIN)
End If
'Dim RESTOY As Single = ARRAYY(Math.Truncate(TIEMPO)) - ALTURA_FIN
'If RESTOY > 0 Then
' ARRAYY.Add(ALTURA_FIN)
'End If
Dim RESTOX As Single = DESPLAZAMIENTOX - ARRAYX(Math.Truncate(TIEMPO))
If RESTOX > 0 Then
ARRAYX.Add(DESPLAZAMIENTOX)
ARRAYY.Add(ALTURA_FIN)
End If
'Dim RESTOY As Single = ARRAYY(Math.Truncate(TIEMPO)) - ALTURA_FIN
'If RESTOY > 0 Then
' ARRAYY.Add(ALTURA_FIN)
'End If
'CALCULO DE LA ALTURA MAXIMA: EN EL PUNTO DE ALTURA MAXIMA LA VELOCIDAD Y = 0 : VECTORY - GRAVEDAD * TIEMPO = 0 => TIEMPO = VECTORY/GRAVEDAD
Dim TIEMPOALTURAMAXIMA As Single = VECTORY / GRAVEDAD
Dim TIEMPOALTURAMAXIMA As Single = VECTORY / GRAVEDAD
'LA ALTURA MAXIMA = ALTURA INICIAL + (VELOCIDAD MEDIA EN Y * TIEMPO EN ALCANZAR LA ALTURA MAXIMA)
Dim YALTURAMAXIMA As Single = ALTURA_INI + ((VECTORY / 2) * TIEMPOALTURAMAXIMA)
Dim YALTURAMAXIMA As Single = ALTURA_INI + ((VECTORY / 2) * TIEMPOALTURAMAXIMA)
'EL PUNTO EN X EN EL MOMENTO EN QUE LA ALTURA ES MAXIMA = VECTORX * TIEMPOALTURAMAXIMA
Dim XALTURAMAXIMA As Single = VECTORX * TIEMPOALTURAMAXIMA
Dim XALTURAMAXIMA As Single = VECTORX * TIEMPOALTURAMAXIMA
LabelCOORDALTURAMAXIMA.Text = Math.Round(XALTURAMAXIMA, 2) & " X , " & Math.Round(YALTURAMAXIMA, 2) & " Y"
'LA VELOCIDAD FINAL EN X SERA LA MISMA QUE LA INCIAL, DADO QUE EN ESTE MOVIMIENTO EL VECTOR X NO VARIA (MOVIMIENTO UNIFORME)
LabelVELOCIDADFINALX.Text = Math.Round(VECTORX, 2) & " m/s"
LabelVELOCIDADFINALX.Text = Math.Round(VECTORX, 2) & " m/s"
' LA VELOCIDAD FINAL EN Y SERA LA RESULTANTE DE Vf= Vo-(GRAVEDAD * TIEMPO)
LabelVELOCIDADFINALY.Text = Math.Round(VECTORY - (GRAVEDAD * TIEMPO), 2) & " m/s" ' SI TIENE SIGNO NEGATIVO SIGNIFICA QUE ESTA BAJANDO
LabelVELOCIDADFINALY.Text = Math.Round(VECTORY - (GRAVEDAD * TIEMPO), 2) & " m/s" ' SI TIENE SIGNO NEGATIVO SIGNIFICA QUE ESTA BAJANDO
Catch ex As Exception
MsgBox("REVISA LOS VALORES INICIALES")
End Try
MsgBox("REVISA LOS VALORES INICIALES")
End Try
End Sub
Public Sub PINTAR()
'DEFINIMOS EL AREA DE DIBUJO DENTRO DEL PICTUREBOX: RESERVAREMOS UN MARGEN A CADA LADO PARA QUE SE VEA MEJOR LA GRAFICA
Dim MARGEN As Integer = 50
Dim ANCHO As Integer = PictureBox1.Width - MARGEN
Dim ALTO As Integer = PictureBox1.Height - MARGEN
'DEFINIMOS LOS ELEMENTOS DE DIBUJO
Dim BM As Bitmap = New Bitmap(PictureBox1.Width, PictureBox1.Height)
Dim DIBUJO As Graphics = Graphics.FromImage(BM)
DIBUJO.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
Dim LAPIZX As New Pen(Brushes.Blue, 6)
Dim LAPIZY As New Pen(Brushes.Red, 6)
Dim FUENTE As New Font("verdana", 8)
Try
'DEFINIMOS EL TRAMO A DIBUJAR EN FUNCION DE LAS DIMENSIONES DEL PICTUREBOX MENOS SUS MARGENES
Dim TRAMO As Single = (ANCHO - MARGEN) / DESPLAZAMIENTOX ' RATIO PARA QUE EL DESPLAZAMIENTO TOTAL SEA IGUAL AL ANCHO DE LA ZONA DE DIBUJO
'DIBUJAMOS X Y SU TEXTO
For I = 0 To CONTADOR
DIBUJO.DrawLine(LAPIZX, MARGEN, ALTO, MARGEN + (ARRAYX(I) * TRAMO), ALTO)
For I = 0 To CONTADOR
DIBUJO.DrawLine(LAPIZX, MARGEN, ALTO, MARGEN + (ARRAYX(I) * TRAMO), ALTO)
Next
DIBUJO.DrawString(Math.Round(ARRAYX(CONTADOR), 2), FUENTE, Brushes.Cyan, CInt(MARGEN + ARRAYX(CONTADOR) * TRAMO), CInt(ALTO))
DIBUJO.DrawString("0", FUENTE, Brushes.Cyan, CInt(MARGEN + ARRAYX(0) * TRAMO), CInt(ALTO))
DIBUJO.DrawString(Math.Round(ARRAYX(CONTADOR), 2), FUENTE, Brushes.Cyan, CInt(MARGEN + ARRAYX(CONTADOR) * TRAMO), CInt(ALTO))
DIBUJO.DrawString("0", FUENTE, Brushes.Cyan, CInt(MARGEN + ARRAYX(0) * TRAMO), CInt(ALTO))
'DIBUJAMOS Y Y SU TEXTO
For I = 0 To CONTADOR - 1
DIBUJO.DrawLine(LAPIZY, CInt(MARGEN + (ARRAYX(I) * TRAMO)), CInt(ALTO - (ARRAYY(I) * TRAMO)), CInt(MARGEN + (ARRAYX(I + 1) * TRAMO)), CInt(ALTO - (ARRAYY(I + 1) * TRAMO)))
For I = 0 To CONTADOR - 1
DIBUJO.DrawLine(LAPIZY, CInt(MARGEN + (ARRAYX(I) * TRAMO)), CInt(ALTO - (ARRAYY(I) * TRAMO)), CInt(MARGEN + (ARRAYX(I + 1) * TRAMO)), CInt(ALTO - (ARRAYY(I + 1) * TRAMO)))
Next
DIBUJO.DrawString(Math.Round(ARRAYY(CONTADOR), 2), FUENTE, Brushes.DeepPink, CInt(MARGEN + ARRAYX(CONTADOR) * TRAMO), CInt(ALTO - MARGEN - (ARRAYY(CONTADOR) * TRAMO)))
DIBUJO.DrawString(TextBoxALT_INI.Text, FUENTE, Brushes.DeepPink, CInt(MARGEN + ARRAYX(0) * TRAMO), CInt(ALTO - (ARRAYY(0) * TRAMO)))
DIBUJO.DrawString(Math.Round(ARRAYY(CONTADOR), 2), FUENTE, Brushes.DeepPink, CInt(MARGEN + ARRAYX(CONTADOR) * TRAMO), CInt(ALTO - MARGEN - (ARRAYY(CONTADOR) * TRAMO)))
DIBUJO.DrawString(TextBoxALT_INI.Text, FUENTE, Brushes.DeepPink, CInt(MARGEN + ARRAYX(0) * TRAMO), CInt(ALTO - (ARRAYY(0) * TRAMO)))
'MOSTRAMOS LA GRAFICA EN EL PICTUREBOX
PictureBox1.Image = BM
Catch ex As Exception
PictureBox1.Image = BM
Catch ex As Exception
End Try
End Sub
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
'CONTROLAMOS QUE EL TIMER SOLO ACTUE EL MISMO NUMERO DE VECES QUE LOS ARRAYS
If CONTADOR < ARRAYX.Count Then
PINTAR()
CONTADOR += 1
Else
Timer1.Enabled = False
End If
'CONTROLAMOS QUE EL TIMER SOLO ACTUE EL MISMO NUMERO DE VECES QUE LOS ARRAYS
If CONTADOR < ARRAYX.Count Then
PINTAR()
CONTADOR += 1
Else
Timer1.Enabled = False
End If
End Sub
End Class
End Class
Clase Math con Visual Basic (VB.NET). Constantes, Potenciacion y Logaritmos, Angulos
Se trata de una pequeña aplicación para ayudar a entender la Clase Math de Visual Studio.
Codigo:
Form1
Public Class Form1
' VALOR ABSOLUTO
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
TextBox2.Text = Math.Round(Math.Abs(CDbl(TextBox1.Text)), CInt(TextBox8.Text))
Catch ex As Exception
MsgBox(ex.Message)
End Try
' VALOR ABSOLUTO
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
TextBox2.Text = Math.Round(Math.Abs(CDbl(TextBox1.Text)), CInt(TextBox8.Text))
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
'ARCOCOSENO
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Try
TextBox3.Text = Math.Round(Math.Acos(CDbl(TextBox4.Text)), CInt(TextBox8.Text))
TextBox5.Text = Math.Round(CDbl(TextBox3.Text) * (180 / Math.PI), CInt(TextBox8.Text))
Catch ex As Exception
MsgBox(ex.Message)
End Try
'ARCOCOSENO
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Try
TextBox3.Text = Math.Round(Math.Acos(CDbl(TextBox4.Text)), CInt(TextBox8.Text))
TextBox5.Text = Math.Round(CDbl(TextBox3.Text) * (180 / Math.PI), CInt(TextBox8.Text))
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
'REDONDEO
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Try
TextBox6.Text = Math.Round(CDbl(TextBox7.Text), CInt(TextBox8.Text))
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
'ARCOSENO
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Try
TextBox10.Text = Math.Round(Math.Asin(CDbl(TextBox11.Text)), CInt(TextBox8.Text))
TextBox9.Text = Math.Round(CDbl(TextBox10.Text) * (180 / Math.PI), CInt(TextBox8.Text))
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
'ARCOTANGENTE
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
Try
TextBox13.Text = Math.Round(Math.Atan(CDbl(TextBox14.Text)), CInt(TextBox8.Text))
TextBox12.Text = Math.Round(CDbl(TextBox13.Text) * (180 / Math.PI), CInt(TextBox8.Text))
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
'COSENO
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
Dim RADIANES As Double = Nothing
Try
If RadioButton1.Checked Then
RADIANES = CDbl(TextBox17.Text) * (Math.PI / 180)
TextBox16.Text = Math.Round(Math.Cos(RADIANES), CInt(TextBox8.Text))
Else
TextBox16.Text = Math.Round(Math.Cos(CDbl(TextBox17.Text)), CInt(TextBox8.Text))
End If
'REDONDEO
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Try
TextBox6.Text = Math.Round(CDbl(TextBox7.Text), CInt(TextBox8.Text))
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
'ARCOSENO
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Try
TextBox10.Text = Math.Round(Math.Asin(CDbl(TextBox11.Text)), CInt(TextBox8.Text))
TextBox9.Text = Math.Round(CDbl(TextBox10.Text) * (180 / Math.PI), CInt(TextBox8.Text))
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
'ARCOTANGENTE
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
Try
TextBox13.Text = Math.Round(Math.Atan(CDbl(TextBox14.Text)), CInt(TextBox8.Text))
TextBox12.Text = Math.Round(CDbl(TextBox13.Text) * (180 / Math.PI), CInt(TextBox8.Text))
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
'COSENO
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
Dim RADIANES As Double = Nothing
Try
If RadioButton1.Checked Then
RADIANES = CDbl(TextBox17.Text) * (Math.PI / 180)
TextBox16.Text = Math.Round(Math.Cos(RADIANES), CInt(TextBox8.Text))
Else
TextBox16.Text = Math.Round(Math.Cos(CDbl(TextBox17.Text)), CInt(TextBox8.Text))
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
'SENO
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
Dim RADIANES As Double = Nothing
MsgBox(ex.Message)
End Try
End Sub
'SENO
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
Dim RADIANES As Double = Nothing
Try
If RadioButton4.Checked Then
RADIANES = CDbl(TextBox18.Text) * (Math.PI / 180)
TextBox15.Text = Math.Round(Math.Sin(RADIANES), CInt(TextBox8.Text))
Else
TextBox15.Text = Math.Round(Math.Sin(CDbl(TextBox18.Text)), CInt(TextBox8.Text))
End If
If RadioButton4.Checked Then
RADIANES = CDbl(TextBox18.Text) * (Math.PI / 180)
TextBox15.Text = Math.Round(Math.Sin(RADIANES), CInt(TextBox8.Text))
Else
TextBox15.Text = Math.Round(Math.Sin(CDbl(TextBox18.Text)), CInt(TextBox8.Text))
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
'EXPONENCIAL E
Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
Try
TextBox19.Text = Math.Round(Math.Exp(CDbl(TextBox20.Text)), CInt(TextBox8.Text))
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
'LOGARITMO NATURAL
Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
Try
TextBox21.Text = Math.Round(Math.Log(CDbl(TextBox22.Text)), CInt(TextBox8.Text))
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
'LOGARITMO DECIMAL
Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
Try
TextBox23.Text = Math.Round(Math.Log10(CDbl(TextBox24.Text)), CInt(TextBox8.Text))
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
MsgBox(ex.Message)
End Try
End Sub
'EXPONENCIAL E
Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
Try
TextBox19.Text = Math.Round(Math.Exp(CDbl(TextBox20.Text)), CInt(TextBox8.Text))
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
'LOGARITMO NATURAL
Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
Try
TextBox21.Text = Math.Round(Math.Log(CDbl(TextBox22.Text)), CInt(TextBox8.Text))
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
'LOGARITMO DECIMAL
Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
Try
TextBox23.Text = Math.Round(Math.Log10(CDbl(TextBox24.Text)), CInt(TextBox8.Text))
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
'EXPONENCIAL CUALQUIER BASE
Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
Try
TextBox25.Text = Math.Round(Math.Pow((CDbl(TextBox26.Text)), (CDbl(TextBox27.Text))), CInt(TextBox8.Text))
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
'RAIZ CUADRADA
Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click
Try
TextBox28.Text = Math.Round(Math.Sqrt(CDbl(TextBox29.Text)), CInt(TextBox8.Text))
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
'LOGARITMO CUALQUIER BASE
Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click
Try
TextBox31.Text = Math.Round(Math.Log((CDbl(TextBox32.Text)), (CDbl(TextBox30.Text))), CInt(TextBox8.Text))
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
'TANGENTE
Private Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click
Try
If RadioButton6.Checked Then
If CDbl(TextBox34.Text) = 90 Or CDbl(TextBox34.Text) = 270 Then
TextBox33.Text = "INFIN."
Else
Dim RADIANES As Double = Nothing
RADIANES = CDbl(TextBox34.Text) * (Math.PI / 180)
TextBox33.Text = Math.Round(Math.Tan(RADIANES), CInt(TextBox8.Text))
End If
Else
TextBox33.Text = Math.Round(Math.Tan(CDbl(TextBox34.Text)), CInt(TextBox8.Text))
End If
Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
Try
TextBox25.Text = Math.Round(Math.Pow((CDbl(TextBox26.Text)), (CDbl(TextBox27.Text))), CInt(TextBox8.Text))
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
'RAIZ CUADRADA
Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click
Try
TextBox28.Text = Math.Round(Math.Sqrt(CDbl(TextBox29.Text)), CInt(TextBox8.Text))
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
'LOGARITMO CUALQUIER BASE
Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click
Try
TextBox31.Text = Math.Round(Math.Log((CDbl(TextBox32.Text)), (CDbl(TextBox30.Text))), CInt(TextBox8.Text))
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
'TANGENTE
Private Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click
Try
If RadioButton6.Checked Then
If CDbl(TextBox34.Text) = 90 Or CDbl(TextBox34.Text) = 270 Then
TextBox33.Text = "INFIN."
Else
Dim RADIANES As Double = Nothing
RADIANES = CDbl(TextBox34.Text) * (Math.PI / 180)
TextBox33.Text = Math.Round(Math.Tan(RADIANES), CInt(TextBox8.Text))
End If
Else
TextBox33.Text = Math.Round(Math.Tan(CDbl(TextBox34.Text)), CInt(TextBox8.Text))
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
'CONSTANTE E
Private Sub Button15_Click(sender As Object, e As EventArgs) Handles Button15.Click
TextBox35.Text = Math.E.ToString
End Sub
'CONSTANTE PI
Private Sub Button16_Click(sender As Object, e As EventArgs) Handles Button16.Click
TextBox36.Text = Math.PI.ToString
End Sub
End Class
MsgBox(ex.Message)
End Try
End Sub
'CONSTANTE E
Private Sub Button15_Click(sender As Object, e As EventArgs) Handles Button15.Click
TextBox35.Text = Math.E.ToString
End Sub
'CONSTANTE PI
Private Sub Button16_Click(sender As Object, e As EventArgs) Handles Button16.Click
TextBox36.Text = Math.PI.ToString
End Sub
End Class
Campo Electrico con Visual basic
Se trata de una pequeña aplicacion para tratar de ayudar a entender el concepto de Campo Electrico.
Codigo:
Form1
Imports System.Drawing.Drawing2D
Public Class Form1
Dim ONDA As Integer
Dim PLUMA As Integer
Dim FLAG As Boolean = False
Dim ONDA As Integer
Dim PLUMA As Integer
Dim FLAG As Boolean = False
Public Sub ONDAS()
Using AZUL As New Pen(Color.Aqua, PLUMA), _
formGraphics As Graphics = Me.CreateGraphics()
formGraphics.DrawEllipse(AZUL, New Rectangle(Panel1.Location.X - ONDA, Panel1.Location.Y - ONDA, Panel1.Width + 2 * ONDA, Panel1.Height + 2 * ONDA))
End Using
End Sub
Using AZUL As New Pen(Color.Aqua, PLUMA), _
formGraphics As Graphics = Me.CreateGraphics()
formGraphics.DrawEllipse(AZUL, New Rectangle(Panel1.Location.X - ONDA, Panel1.Location.Y - ONDA, Panel1.Width + 2 * ONDA, Panel1.Height + 2 * ONDA))
End Using
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If Button1.Text = "INICIAR" Then
Timer1.Enabled = True
Button1.Text = "PARAR"
ONDA = 50
PLUMA = 16
Else
Timer1.Enabled = False
Button1.Text = "INICIAR"
End If
If Button1.Text = "INICIAR" Then
Timer1.Enabled = True
Button1.Text = "PARAR"
ONDA = 50
PLUMA = 16
Else
Timer1.Enabled = False
Button1.Text = "INICIAR"
End If
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
ONDAS()
If ONDA < CInt(Me.Height / 2) Then
ONDA = ONDA + 50
Else
Refresh()
ONDA = 50
PLUMA = 16
End If
If PLUMA > 0 Then
PLUMA = PLUMA - 2
End If
ONDAS()
If ONDA < CInt(Me.Height / 2) Then
ONDA = ONDA + 50
Else
Refresh()
ONDA = 50
PLUMA = 16
End If
If PLUMA > 0 Then
PLUMA = PLUMA - 2
End If
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
For Each GB As Control In Me.Controls
If GB.GetType Is GetType(Panel) Then
Dim roundPath As New GraphicsPath()
Dim R As New Rectangle(0, 0, GB.Height, GB.Height)
roundPath.AddEllipse(R)
GB.Region = New Region(roundPath)
For Each GB As Control In Me.Controls
If GB.GetType Is GetType(Panel) Then
Dim roundPath As New GraphicsPath()
Dim R As New Rectangle(0, 0, GB.Height, GB.Height)
roundPath.AddEllipse(R)
GB.Region = New Region(roundPath)
End If
Next
POSICION()
BackColor = Color.Black
Next
POSICION()
BackColor = Color.Black
End Sub
Public Sub POSICION()
Label1.Text = "X: " & Panel1.Location.X
Label2.Text = "Y: " & Panel1.Location.Y
Label4.Text = "X: " & Panel2.Location.X
Label5.Text = "Y: " & Panel2.Location.Y
End Sub
Public Sub POSICION()
Label1.Text = "X: " & Panel1.Location.X
Label2.Text = "Y: " & Panel1.Location.Y
Label4.Text = "X: " & Panel2.Location.X
Label5.Text = "Y: " & Panel2.Location.Y
End Sub
Private Sub Panel1_MouseDown(sender As Object, e As MouseEventArgs) Handles Panel1.MouseDown
FLAG = True
End Sub
FLAG = True
End Sub
Private Sub Panel1_MouseMove(sender As Object, e As MouseEventArgs) Handles Panel1.MouseMove
If FLAG = True Then
Panel1.Location = New Point(Panel1.Location.X + e.X, Panel1.Location.Y + e.Y)
Label1.Text = "X: " & Panel1.Location.X
Label2.Text = "Y: " & Panel1.Location.Y
If FLAG = True Then
Panel1.Location = New Point(Panel1.Location.X + e.X, Panel1.Location.Y + e.Y)
Label1.Text = "X: " & Panel1.Location.X
Label2.Text = "Y: " & Panel1.Location.Y
End If
End Sub
End Sub
Private Sub Panel1_MouseUp(sender As Object, e As MouseEventArgs) Handles Panel1.MouseUp
FLAG = False
End Sub
Private Sub Panel2_MouseDown(sender As Object, e As MouseEventArgs) Handles Panel2.MouseDown
FLAG = True
End Sub
FLAG = False
End Sub
Private Sub Panel2_MouseDown(sender As Object, e As MouseEventArgs) Handles Panel2.MouseDown
FLAG = True
End Sub
Private Sub Panel2_MouseMove(sender As Object, e As MouseEventArgs) Handles Panel2.MouseMove
If FLAG = True Then
Panel2.Location = New Point(Panel2.Location.X + e.X, Panel2.Location.Y + e.Y)
Label4.Text = "X: " & Panel2.Location.X
Label5.Text = "Y: " & Panel2.Location.Y
If FLAG = True Then
Panel2.Location = New Point(Panel2.Location.X + e.X, Panel2.Location.Y + e.Y)
Label4.Text = "X: " & Panel2.Location.X
Label5.Text = "Y: " & Panel2.Location.Y
End If
End Sub
End Sub
Private Sub Panel2_MouseUp(sender As Object, e As MouseEventArgs) Handles Panel2.MouseUp
FLAG = False
End Sub
FLAG = False
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
PictureBox2.Visible = True
End Sub
Public Sub FLECHAS()
Refresh()
If CInt(TextBox1.Text) < 0 Then
Panel1.BackColor = Color.Blue
Else
Panel1.BackColor = Color.Orange
End If
Dim FLECHA As Integer = Panel1.Width
Dim COLORF As Pen
If Panel1.BackColor = Color.Orange Then
COLORF = New Pen(Color.Red, 10)
COLORF.SetLineCap(0, LineCap.ArrowAnchor, DashCap.Triangle)
Else
COLORF = New Pen(Color.Aqua, 10)
COLORF.SetLineCap(LineCap.ArrowAnchor, 0, DashCap.Triangle)
End If
PictureBox2.Visible = True
End Sub
Public Sub FLECHAS()
Refresh()
If CInt(TextBox1.Text) < 0 Then
Panel1.BackColor = Color.Blue
Else
Panel1.BackColor = Color.Orange
End If
Dim FLECHA As Integer = Panel1.Width
Dim COLORF As Pen
If Panel1.BackColor = Color.Orange Then
COLORF = New Pen(Color.Red, 10)
COLORF.SetLineCap(0, LineCap.ArrowAnchor, DashCap.Triangle)
Else
COLORF = New Pen(Color.Aqua, 10)
COLORF.SetLineCap(LineCap.ArrowAnchor, 0, DashCap.Triangle)
End If
Dim FUERZA As Graphics = Me.CreateGraphics()
FUERZA.DrawLine(COLORF, Panel1.Location.X, Panel1.Location.Y, Panel1.Location.X - FLECHA, Panel1.Location.Y - FLECHA)
FUERZA.DrawLine(COLORF, Panel1.Location.X + Panel1.Width, Panel1.Location.Y + Panel1.Height, Panel1.Location.X + Panel1.Width + FLECHA, Panel1.Location.Y + Panel1.Height + FLECHA)
FUERZA.DrawLine(COLORF, Panel1.Location.X + Panel1.Width, Panel1.Location.Y, Panel1.Location.X + Panel1.Width + FLECHA, Panel1.Location.Y - FLECHA)
FUERZA.DrawLine(COLORF, Panel1.Location.X, Panel1.Location.Y + Panel1.Height, Panel1.Location.X - FLECHA, Panel1.Location.Y + Panel1.Height + FLECHA)
FUERZA.DrawLine(COLORF, Panel1.Location.X + CInt(Panel1.Width / 2), Panel1.Location.Y - 50, Panel1.Location.X + CInt(Panel1.Width / 2), Panel1.Location.Y - FLECHA - 50)
FUERZA.DrawLine(COLORF, Panel1.Location.X + CInt(Panel1.Width / 2), Panel1.Location.Y + Panel1.Height + 50, Panel1.Location.X + CInt(Panel1.Width / 2), Panel1.Location.Y + Panel1.Height + FLECHA + 50)
FUERZA.DrawLine(COLORF, Panel1.Location.X - 50, Panel1.Location.Y + CInt(Panel1.Height / 2), Panel1.Location.X - FLECHA - 50, Panel1.Location.Y + CInt(Panel1.Height / 2))
FUERZA.DrawLine(COLORF, Panel1.Location.X + 50 + Panel1.Width, Panel1.Location.Y + CInt(Panel1.Height / 2), Panel1.Location.X + Panel1.Width + FLECHA + 50, Panel1.Location.Y + CInt(Panel1.Height / 2))
FUERZA.DrawLine(COLORF, Panel1.Location.X, Panel1.Location.Y, Panel1.Location.X - FLECHA, Panel1.Location.Y - FLECHA)
FUERZA.DrawLine(COLORF, Panel1.Location.X + Panel1.Width, Panel1.Location.Y + Panel1.Height, Panel1.Location.X + Panel1.Width + FLECHA, Panel1.Location.Y + Panel1.Height + FLECHA)
FUERZA.DrawLine(COLORF, Panel1.Location.X + Panel1.Width, Panel1.Location.Y, Panel1.Location.X + Panel1.Width + FLECHA, Panel1.Location.Y - FLECHA)
FUERZA.DrawLine(COLORF, Panel1.Location.X, Panel1.Location.Y + Panel1.Height, Panel1.Location.X - FLECHA, Panel1.Location.Y + Panel1.Height + FLECHA)
FUERZA.DrawLine(COLORF, Panel1.Location.X + CInt(Panel1.Width / 2), Panel1.Location.Y - 50, Panel1.Location.X + CInt(Panel1.Width / 2), Panel1.Location.Y - FLECHA - 50)
FUERZA.DrawLine(COLORF, Panel1.Location.X + CInt(Panel1.Width / 2), Panel1.Location.Y + Panel1.Height + 50, Panel1.Location.X + CInt(Panel1.Width / 2), Panel1.Location.Y + Panel1.Height + FLECHA + 50)
FUERZA.DrawLine(COLORF, Panel1.Location.X - 50, Panel1.Location.Y + CInt(Panel1.Height / 2), Panel1.Location.X - FLECHA - 50, Panel1.Location.Y + CInt(Panel1.Height / 2))
FUERZA.DrawLine(COLORF, Panel1.Location.X + 50 + Panel1.Width, Panel1.Location.Y + CInt(Panel1.Height / 2), Panel1.Location.X + Panel1.Width + FLECHA + 50, Panel1.Location.Y + CInt(Panel1.Height / 2))
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Timer1.Enabled = False
Timer2.Enabled = True
FLECHAS()
End Sub
Timer1.Enabled = False
Timer2.Enabled = True
FLECHAS()
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Panel2.Visible = True
End Sub
Panel2.Visible = True
End Sub
Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
If CInt(TextBox1.Text) < 0 Then
Panel1.BackColor = Color.Blue
Else
Panel1.BackColor = Color.Orange
End If
Dim CX As Integer = (Math.Abs(Panel2.Location.X - Panel1.Location.X)) ^ 2
Dim CY As Integer = (Math.Abs(Panel2.Location.Y - Panel2.Location.Y)) ^ 2
Dim DISTANCIA2 As Single = (CX / 1000) + (CY / 1000)
Dim CAMPO As Single = Math.Round((9 * CInt(TextBox1.Text) / DISTANCIA2), 4)
Label7.Text = "E: " & CAMPO.ToString
FLECHAS()
If CInt(TextBox1.Text) < 0 Then
Panel1.BackColor = Color.Blue
Else
Panel1.BackColor = Color.Orange
End If
Dim CX As Integer = (Math.Abs(Panel2.Location.X - Panel1.Location.X)) ^ 2
Dim CY As Integer = (Math.Abs(Panel2.Location.Y - Panel2.Location.Y)) ^ 2
Dim DISTANCIA2 As Single = (CX / 1000) + (CY / 1000)
Dim CAMPO As Single = Math.Round((9 * CInt(TextBox1.Text) / DISTANCIA2), 4)
Label7.Text = "E: " & CAMPO.ToString
FLECHAS()
End Sub
Public Sub PINTAR()
Dim ROJO As New Pen(Color.Red, 10)
ROJO.SetLineCap(LineCap.ArrowAnchor, LineCap.ArrowAnchor, DashCap.Triangle)
Dim FUERZA As Graphics = Me.CreateGraphics()
FUERZA.DrawLine(ROJO, Panel1.Location.X, Panel1.Location.Y, Panel2.Location.X, Panel2.Location.Y)
Dim FUENTE As New System.Drawing.Font("Arial", 16, FontStyle.Bold)
FUERZA.DrawString("r (E) ", FUENTE, Brushes.Yellow, CInt((Panel1.Location.X + Panel2.Location.X) / 2), CInt((Panel1.Location.Y + Panel2.Location.Y) / 2))
ROJO.SetLineCap(LineCap.ArrowAnchor, LineCap.ArrowAnchor, DashCap.Triangle)
Dim FUERZA As Graphics = Me.CreateGraphics()
FUERZA.DrawLine(ROJO, Panel1.Location.X, Panel1.Location.Y, Panel2.Location.X, Panel2.Location.Y)
Dim FUENTE As New System.Drawing.Font("Arial", 16, FontStyle.Bold)
FUERZA.DrawString("r (E) ", FUENTE, Brushes.Yellow, CInt((Panel1.Location.X + Panel2.Location.X) / 2), CInt((Panel1.Location.Y + Panel2.Location.Y) / 2))
Dim AMARILLO As New Pen(Color.Yellow, 8)
AMARILLO.SetLineCap(LineCap.ArrowAnchor, LineCap.ArrowAnchor, DashCap.Triangle)
Dim COMPONENTES As Graphics = Me.CreateGraphics()
COMPONENTES.DrawLine(AMARILLO, Panel1.Location.X, Panel1.Location.Y, Panel2.Location.X, Panel1.Location.Y)
COMPONENTES.DrawString("X = (PX-X1)", FUENTE, Brushes.Yellow, CInt((Panel1.Location.X + Panel2.Location.X) / 2), Panel1.Location.Y)
AMARILLO.SetLineCap(LineCap.ArrowAnchor, LineCap.ArrowAnchor, DashCap.Triangle)
Dim COMPONENTES As Graphics = Me.CreateGraphics()
COMPONENTES.DrawLine(AMARILLO, Panel1.Location.X, Panel1.Location.Y, Panel2.Location.X, Panel1.Location.Y)
COMPONENTES.DrawString("X = (PX-X1)", FUENTE, Brushes.Yellow, CInt((Panel1.Location.X + Panel2.Location.X) / 2), Panel1.Location.Y)
COMPONENTES.DrawLine(AMARILLO, Panel2.Location.X, Panel1.Location.Y, Panel2.Location.X, Panel2.Location.Y)
COMPONENTES.DrawString(" Y = (PY-Y1)", FUENTE, Brushes.Yellow, Panel2.Location.X, Panel2.Location.Y + CInt((Panel1.Location.Y - Panel2.Location.Y) / 2))
If CInt(TextBox1.Text) < 0 Then
Panel1.BackColor = Color.Blue
Else
Panel1.BackColor = Color.Orange
End If
Dim CX As Integer = (Math.Abs(Panel2.Location.X - Panel1.Location.X)) ^ 2
Dim CY As Integer = (Math.Abs(Panel2.Location.Y - Panel2.Location.Y)) ^ 2
Dim DISTANCIA2 As Single = (CX / 1000) + (CY / 1000)
Dim CAMPO As Single = Math.Round((9 * CInt(TextBox1.Text) / DISTANCIA2), 4)
Label7.Text = "E: " & CAMPO.ToString
End Sub
COMPONENTES.DrawString(" Y = (PY-Y1)", FUENTE, Brushes.Yellow, Panel2.Location.X, Panel2.Location.Y + CInt((Panel1.Location.Y - Panel2.Location.Y) / 2))
If CInt(TextBox1.Text) < 0 Then
Panel1.BackColor = Color.Blue
Else
Panel1.BackColor = Color.Orange
End If
Dim CX As Integer = (Math.Abs(Panel2.Location.X - Panel1.Location.X)) ^ 2
Dim CY As Integer = (Math.Abs(Panel2.Location.Y - Panel2.Location.Y)) ^ 2
Dim DISTANCIA2 As Single = (CX / 1000) + (CY / 1000)
Dim CAMPO As Single = Math.Round((9 * CInt(TextBox1.Text) / DISTANCIA2), 4)
Label7.Text = "E: " & CAMPO.ToString
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
For Each GB As Control In Me.Controls
If GB.GetType Is GetType(Panel) Then
Dim RECTANGULO As New GraphicsPath()
Dim R As New Rectangle(0, 0, GB.Height, GB.Height)
RECTANGULO.AddRectangle(R)
GB.Region = New Region(RECTANGULO)
For Each GB As Control In Me.Controls
If GB.GetType Is GetType(Panel) Then
Dim RECTANGULO As New GraphicsPath()
Dim R As New Rectangle(0, 0, GB.Height, GB.Height)
RECTANGULO.AddRectangle(R)
GB.Region = New Region(RECTANGULO)
End If
Next
Label13.Visible = True
Label15.Visible = True
Label17.Visible = True
PictureBox2.Visible = False
Timer2.Enabled = False
Timer3.Enabled = True
End Sub
Next
Label13.Visible = True
Label15.Visible = True
Label17.Visible = True
PictureBox2.Visible = False
Timer2.Enabled = False
Timer3.Enabled = True
End Sub
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
Timer1.Enabled = False
Timer2.Enabled = False
Timer1.Enabled = False
Timer2.Enabled = False
TRES_Q.Show()
End Sub
End Sub
Private Sub Timer3_Tick(sender As Object, e As EventArgs) Handles Timer3.Tick
Refresh()
PINTAR()
End Sub
Refresh()
PINTAR()
End Sub
Private Sub Label13_MouseDown(sender As Object, e As MouseEventArgs) Handles Label13.MouseDown
FLAG = True
End Sub
FLAG = True
End Sub
Private Sub Label13_MouseMove(sender As Object, e As MouseEventArgs) Handles Label13.MouseMove
If FLAG = True Then
Label13.Location = New Point(Label13.Location.X + e.X, Label13.Location.Y + e.Y)
End If
End Sub
If FLAG = True Then
Label13.Location = New Point(Label13.Location.X + e.X, Label13.Location.Y + e.Y)
End If
End Sub
Private Sub Label13_MouseUp(sender As Object, e As MouseEventArgs) Handles Label13.MouseUp
FLAG = False
End Sub
End Class
FLAG = False
End Sub
End Class
TRES Q
Imports System.Drawing.Drawing2D
Public Class TRES_Q
Public Class TRES_Q
Public Sub PINTAR()
Dim ROJO As New Pen(Color.Red, 10)
ROJO.SetLineCap(LineCap.ArrowAnchor, LineCap.ArrowAnchor, DashCap.Triangle)
Dim FUERZA As Graphics = Me.CreateGraphics()
FUERZA.DrawLine(ROJO, Panel1.Location.X, Panel1.Location.Y, Panel2.Location.X, Panel2.Location.Y)
FUERZA.DrawLine(ROJO, Panel2.Location.X, Panel2.Location.Y, Panel3.Location.X, Panel3.Location.Y)
Dim FUENTE As New System.Drawing.Font("Arial", 16, FontStyle.Bold)
FUERZA.DrawString("d (E1) ", FUENTE, Brushes.Yellow, CInt((Panel1.Location.X + Panel2.Location.X) / 2), CInt((Panel1.Location.Y + Panel2.Location.Y) / 2))
FUERZA.DrawString("d (E2) ", FUENTE, Brushes.Yellow, CInt((Panel2.Location.X + Panel3.Location.X) / 2), CInt((Panel2.Location.Y + Panel3.Location.Y) / 2))
Dim AMARILLO As New Pen(Color.Yellow, 8)
AMARILLO.SetLineCap(LineCap.ArrowAnchor, LineCap.ArrowAnchor, DashCap.Triangle)
Dim ROJO As New Pen(Color.Red, 10)
ROJO.SetLineCap(LineCap.ArrowAnchor, LineCap.ArrowAnchor, DashCap.Triangle)
Dim FUERZA As Graphics = Me.CreateGraphics()
FUERZA.DrawLine(ROJO, Panel1.Location.X, Panel1.Location.Y, Panel2.Location.X, Panel2.Location.Y)
FUERZA.DrawLine(ROJO, Panel2.Location.X, Panel2.Location.Y, Panel3.Location.X, Panel3.Location.Y)
Dim FUENTE As New System.Drawing.Font("Arial", 16, FontStyle.Bold)
FUERZA.DrawString("d (E1) ", FUENTE, Brushes.Yellow, CInt((Panel1.Location.X + Panel2.Location.X) / 2), CInt((Panel1.Location.Y + Panel2.Location.Y) / 2))
FUERZA.DrawString("d (E2) ", FUENTE, Brushes.Yellow, CInt((Panel2.Location.X + Panel3.Location.X) / 2), CInt((Panel2.Location.Y + Panel3.Location.Y) / 2))
Dim AMARILLO As New Pen(Color.Yellow, 8)
AMARILLO.SetLineCap(LineCap.ArrowAnchor, LineCap.ArrowAnchor, DashCap.Triangle)
Dim COMPONENTES As Graphics = Me.CreateGraphics()
COMPONENTES.DrawLine(AMARILLO, Panel1.Location.X, Panel1.Location.Y, Panel2.Location.X, Panel1.Location.Y)
COMPONENTES.DrawLine(AMARILLO, Panel2.Location.X, Panel2.Location.Y, Panel3.Location.X, Panel2.Location.Y)
COMPONENTES.DrawLine(AMARILLO, Panel1.Location.X, Panel1.Location.Y, Panel2.Location.X, Panel1.Location.Y)
COMPONENTES.DrawLine(AMARILLO, Panel2.Location.X, Panel2.Location.Y, Panel3.Location.X, Panel2.Location.Y)
COMPONENTES.DrawString("X = (PX-X1)", FUENTE, Brushes.Yellow, CInt((Panel1.Location.X + Panel2.Location.X) / 2), Panel1.Location.Y)
COMPONENTES.DrawString("X = (X2-PX)", FUENTE, Brushes.Yellow, CInt((Panel2.Location.X + Panel3.Location.X) / 2), Panel2.Location.Y)
COMPONENTES.DrawLine(AMARILLO, Panel2.Location.X, Panel1.Location.Y, Panel2.Location.X, Panel2.Location.Y)
COMPONENTES.DrawLine(AMARILLO, Panel3.Location.X, Panel2.Location.Y, Panel3.Location.X, Panel3.Location.Y)
COMPONENTES.DrawString(" Y = (PY-Y1)", FUENTE, Brushes.Yellow, Panel2.Location.X, Panel2.Location.Y + CInt((Panel1.Location.Y - Panel2.Location.Y) / 2))
COMPONENTES.DrawString("X = (X2-PX)", FUENTE, Brushes.Yellow, CInt((Panel2.Location.X + Panel3.Location.X) / 2), Panel2.Location.Y)
COMPONENTES.DrawLine(AMARILLO, Panel2.Location.X, Panel1.Location.Y, Panel2.Location.X, Panel2.Location.Y)
COMPONENTES.DrawLine(AMARILLO, Panel3.Location.X, Panel2.Location.Y, Panel3.Location.X, Panel3.Location.Y)
COMPONENTES.DrawString(" Y = (PY-Y1)", FUENTE, Brushes.Yellow, Panel2.Location.X, Panel2.Location.Y + CInt((Panel1.Location.Y - Panel2.Location.Y) / 2))
COMPONENTES.DrawString(" Y = (Y2-PY)", FUENTE, Brushes.Yellow, Panel3.Location.X, Panel3.Location.Y + CInt((Panel2.Location.Y - Panel3.Location.Y) / 2))
Dim AZUL As New Pen(Color.Aqua, 8)
AZUL.SetLineCap(LineCap.ArrowAnchor, LineCap.ArrowAnchor, DashCap.Triangle)
COMPONENTES.DrawLine(AZUL, Panel2.Location.X - 15, Panel1.Location.Y, Panel2.Location.X - 15, Panel2.Location.Y)
COMPONENTES.DrawString("E RESULTANTE", FUENTE, Brushes.Aqua, Panel2.Location.X, Panel2.Location.Y + CInt((Panel1.Location.Y - Panel2.Location.Y + 50) / 2))
Dim AZUL As New Pen(Color.Aqua, 8)
AZUL.SetLineCap(LineCap.ArrowAnchor, LineCap.ArrowAnchor, DashCap.Triangle)
COMPONENTES.DrawLine(AZUL, Panel2.Location.X - 15, Panel1.Location.Y, Panel2.Location.X - 15, Panel2.Location.Y)
COMPONENTES.DrawString("E RESULTANTE", FUENTE, Brushes.Aqua, Panel2.Location.X, Panel2.Location.Y + CInt((Panel1.Location.Y - Panel2.Location.Y + 50) / 2))
If TextBox1.Text < 0 Then
Panel1.BackColor = Color.Blue
Panel1.BackColor = Color.Blue
ElseIf TextBox1.Text > 0 Then
Panel1.BackColor = Color.Orange
End If
Panel1.BackColor = Color.Orange
End If
If TextBox2.Text < 0 Then
Panel2.BackColor = Color.Blue
Panel2.BackColor = Color.Blue
ElseIf TextBox2.Text > 0 Then
Panel2.BackColor = Color.Orange
End If
Panel2.BackColor = Color.Orange
End If
End Sub
Private Sub TRES_CARGAS_Load(sender As Object, e As EventArgs) Handles MyBase.Load
BackColor = Color.Black
BackColor = Color.Black
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
PINTAR()
End Sub
End Class
PINTAR()
End Sub
End Class
hola no tendran un video del diceño de formulario paso a paso
ResponderEliminarHola: No tengo ninguno sobre eso. Es un tema muy elemental. Mis aplicaciones suelen ser un poco mas complejas. Puedes encontrarlo en cualquier canal de tutoriales de VB que empiecen desde cero. Saludos.
Eliminarbro me puedes dar la clave de acceso?
ResponderEliminar