0% found this document useful (0 votes)
42 views

Ingrese (H+)

The document contains code for multiple classes (Form1, Form2, Form3) that define the behavior of buttons and fields in different forms/windows of a Visual Basic application. Form1 allows switching between Form2 and Form3. Form2 allows input of data, calculations of averages and clearing of fields. Form3 allows calculations based on input values. The code also contains modules for global variables shared between forms.

Uploaded by

Carlos Santiago
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

Ingrese (H+)

The document contains code for multiple classes (Form1, Form2, Form3) that define the behavior of buttons and fields in different forms/windows of a Visual Basic application. Form1 allows switching between Form2 and Form3. Form2 allows input of data, calculations of averages and clearing of fields. Form3 allows calculations based on input values. The code also contains modules for global variables shared between forms.

Uploaded by

Carlos Santiago
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Public Class Form1

Private Sub Button1_Click(ByVal se


Me.Hide()
Form2.Show()
End Sub

Private Sub Button2_Click(ByVal
Me.Hide()
Form3.Show()
End Sub

Private Sub Button3_Click(ByVal s
End
End Sub
End Class


Public Class Form2
Private Sub Button1_Cli
NDATOS = Val(TextBox1.Text)
For i As Single = 0 To NDATOS - 1
H1(i) = Val(InputBox("Ingrese [H+]" & i))
ListBox1.Items.Add(H1(i))
Next i
For i As Single = 0 To NDATOS - 1
pH(i) = -Math.Log(H1(i)) / 2.3026
ListBox2.Items.Add(pH(i))
Next i
For i As Single = 0 To NDATOS - 1
pOH(i) = (14 - pH(i))
ListBox3.Items.Add(pOH(i))
Next i
End Sub

Private Sub Button3_Click(ByV
TextBox1.Text = " "
TextBox2.Text = " "
TextBox3.Text = " "
TextBox4.Text = " "
ListBox1.Items.Clear()
ListBox2.Items.Clear()
ListBox3.Items.Clear()
TextBox1.Focus()
End Sub

Private Sub Button4_Click(
Me.Hide()
Form1.Show()
End Sub

Private Sub Button5_Click(
End
End Sub

Private Sub Button2_Click(ByVal
PROMH = 0
PROMpH = 0
PROMpOH = 0

For i As Integer = 0 To NDATOS - 1
PROMH = PROMH + H1(i)
PROMpH = PROMpH + pH(i)
PROMpOH = PROMpOH + pOH(i)
Next i
PROMH = PROMH / NDATOS
PROMpH = PROMpH / NDATOS
PROMpOH = PROMpOH / NDATOS
TextBox2.Text = PROMH
TextBox3.Text = PROMpH
TextBox4.Text = PROMpOH
End Sub

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load

End Sub
End Class

Public Class Form3

Private Sub Button1_
Dim C1, C2, V1, V2 As Single
Dim CF As Single
C1 = Val(TextBox1.Text)
V1 = Val(TextBox2.Text)
C1 = Val(TextBox3.Text)
V2 = Val(TextBox4.Text)
CF = (C1 * V2 + C2 * V2) / (V1 + V2)
TextBox5.Text = CF
End Sub

Private Sub Button2_Clic
TextBox1.Text = " "
TextBox2.Text = " "
TextBox3.Text = " "
TextBox4.Text = " "
TextBox5.Text = ""
End Sub

Private Sub Button3_Click
Me.Hide()
Form1.Show()
End Sub

Private Sub Button4_
End
End Sub
End Class
Module
Module Module1
Public NDATOS As Single
Public H1(100) As Single
Public pH(100) As Single
Public pOH(100) As Single
Public PROMH As Single
Public PROMpH As Single
Public PROMpOH As Single

End Module



GASES IDEALES

Public Class Form1
Dim ops As Byte
Dim p As Integer
Dim t As Integer
Dim v As Integer
Dim N As Integer
Private Sub Button1_Click(
Dim P, V, N, T As Double
Select Case Opacity
Case 1
V = Val(TextBox1.Text)
T = Val(TextBox2.Text)
N = Val(TextBox3.Text)
P = (N * 0.08205 * T) / V
TextBox4.Text = P
Case 2
P = Val(TextBox1.Text)
T = Val(TextBox2.Text)
N = Val(TextBox3.Text)
V = (N * 0.08205 * T) / P
TextBox4.Text = V
Case 3
P = Val(TextBox1.Text)
V = Val(TextBox2.Text)
N = Val(TextBox3.Text)
T = (P * V) / (N * 0.08205)
TextBox4.Text = T
Case 4
P = Val(TextBox1.Text)
V = Val(TextBox2.Text)
T = Val(TextBox3.Text)
N = (P * V) / (T * 0.08205)
TextBox4.Text = N
End Select
End Sub
Private Sub RadioButton1_CheckedChanged(
Label4.Text = "V"
Label7.Text = "L"
Label5.Text = "T"
Label8.Text = "K"
Label6.Text = "N"
Label9.Text = "mol"
Label12.Text = "ATM"
Label11.Text = "P"
ops = 1
End Sub
Private Sub RadioButton2_CheckedChanged(
Label4.Text = "p"
Label7.Text = "ATM"
Label5.Text = "T"
Label8.Text = "K"
Label6.Text = "N"
Label9.Text = "mol"
Label11.Text = "V"
Label12.Text = "L"
ops = 2
End Sub
Private Sub RadioButton3_CheckedChanged(
Label4.Text = "p"
Label7.Text = "ATM"
Label5.Text = "V"
Label8.Text = "L"
Label6.Text = "N"
Label9.Text = "mol"
Label11.Text = "T"
Label12.Text = "K"
ops = 3
End Sub
Private Sub RadioButton4_CheckedChanged(ByVal s
Label4.Text = "p"
Label7.Text = "ATM"
Label5.Text = "V"
Label8.Text = "L"
Label6.Text = "T"
Label9.Text = "K"
Label11.Text = "N"
Label12.Text = "mol"
ops = 4
End Sub
Private Sub Button2_Click(
Label4.Text = ""
Label5.Text = ""
Label6.Text = ""
Label7.Text = ""
Label8.Text = ""
Label9.Text = ""
Label10.Text = ""
Label11.Text = ""
Label12.Text = ""
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
End Sub

Private Sub Button3_Click_1(B
End
End Sub
End Class






Tab Control


Public Class Form1
Dim ID As Single
Dim Ndatos As Integer
Dim N1(100) As Single
Dim N2(100) As Single
Dim N3(100) As Single
Dim PROM(100) As Single
Dim Max1 As Single
Dim Min1 As Single
Dim Max2 As Single
Dim Min2 As Single
Dim Max3 As Single
Dim Min3 As Single
Dim m As Single
Dim V As Single
Dim D As Single
Private Sub Button1_Click
End
End Sub

Private Sub Button2_Click(
Ndatos = Val(TextBox1.Text)
For I As Integer = 0 To Ndatos - 1
N1(I) = Val(InputBox("ingrese nota 1 -" & I + 1))
ListBox1.Items.Add(N1(I))
N2(I) = Val(InputBox("ingrese nota 2 -" & I + 1))
ListBox2.Items.Add(N2(I))
N3(I) = Val(InputBox("INGRESE nota 3 -" & I + 1))
ListBox3.Items.Add(N3(I))
Next I
End Sub

Private Sub Button3_Click(
TextBox1.Text = ""
ListBox1.Items.Clear()
ListBox2.Items.Clear()
ListBox3.Items.Clear()
End Sub

Private Sub Button4_Click(
Max1 = 0
Max2 = 0
Max3 = 0
Min1 = 20
Min2 = 20
Min3 = 20
For I As Integer = 0 To Ndatos - 1
If Max1 < N1(I) Then
Max1 = N1(I)
End If
Next I
TextBox2.Text = Format(Max1, "##0,0")
For I As Integer = 0 To Ndatos - 1
If Min1 > N1(I) Then
Min1 = N1(I)
End If
Next I
TextBox3.Text = Format(Min1, "##0,0")
For I As Integer = 0 To Ndatos - 1
If Max2 < N2(I) Then
Max2 = N2(I)
End If
Next I
TextBox4.Text = Format(Max2, "##0,0")
For I As Integer = 0 To Ndatos - 1
If Min2 > N2(I) Then
Min2 = N2(I)
End If
Next I
TextBox5.Text = Format(Min2, "##0,0")
For I As Integer = 0 To Ndatos - 1
If Max3 < N3(I) Then
Max3 = N3(I)
End If
Next I
TextBox6.Text = Format(Max3, "##0,0")
For I As Integer = 0 To Ndatos - 1
If Min3 > N3(I) Then
Min3 = N3(I)
End If
Next I
TextBox7.Text = Format(Min3, "##0,0")

For I As Integer = 0 To Ndatos - 1
PROM(I) = (N1(I) + N2(I) + N3(I)) / 3
ListBox4.Items.Add(Format("##.00", PROM(I)))
Next
End Sub

Private Sub Button5_Click(
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
ListBox4.Items.Clear()
End Sub

Private Sub Button6_Click(
m = Val(TextBox8.Text)
V = Val(TextBox9.Text)
D = m / V
TextBox10.Text = D
End Sub

Private Sub Button7_Click(
TextBox8.Text = ""
TextBox9.Text = ""
TextBox10.Text = ""
End Sub

Private Sub Button8_Click
ID = Shell("C:\Program Files (x86)\Microsoft Office\Office14\WINWORD.EXE", 1)
End Sub

Private Sub Button9_Clic
ID = Shell("C:\Program Files (x86)\Microsoft Office\Office14\excel.EXE", 1)
End Sub

Private Sub Button10_Click
ID = Shell("C:\Program Files (x86)\Microsoft Office\Office14\POWERPNT.EXE", 1)
End Sub
End Class
Uso del for to next

Public Class Form1
Dim Ndatos As Integer
Dim H(1000) As Single
Dim pH(1000) As Single
Dim pOH(1000) As Single
Dim media(H(1000)) As Single
Dim DS(H(1000)) As Single

Private Sub Button1_Click(
Ndatos = Val(TextBox1.Text)
For i As Integer = 0 To Ndatos - 1
H(i) = Val(InputBox("Ingrese el valor N." & i))
ListBox1.Items.Add(H(i))
Next (i)
End Sub

Private Sub Button2_Click(
ListBox1.Items.Remove(ListBox1.SelectedItem())
For i As Integer = 0 To (ListBox1.Items.Count() - 1)
H(i) = 0
H(i) = Val(ListBox1.Items.Item(i))
Next (i)
End Sub

Private Sub Button3_Click(
For i As Integer = 0 To (ListBox1.Items.Count() - 1)
pH(i) = -Math.Log10(H(i))
pOH(i) = 14 - pH(i)
ListBox2.Items.Add(pH(i))
ListBox3.Items.Add(pOH(i))
Next (i)
End Sub

Private Sub Button4_Click(
media(H(1000)) = 0
media(pH(1000)) = 0
media(pOH(1000)) = 0
DS(H(1000)) = 0
DS(pH(1000)) = 0
DS(pOH(1000)) = 0
For i As Integer = 0 To (ListBox1.Items.Count() - 1)
media(H(1000)) = media(H(1000)) + H(i)
media(pH(1000)) = media(pH(1000)) + pH(i)
media(pOH(1000)) = media(pOH(1000)) + pOH(i)
Next (i)
media(H(1000)) = media(H(1000)) / (ListBox1.Items.Count())
media(pH(1000)) = media(pH(1000)) / (ListBox1.Items.Count())
media(pOH(1000)) = media(pOH(1000)) / (ListBox1.Items.Count())
TextBox2.Text = media(H(1000))
TextBox3.Text = media(pH(1000))
TextBox4.Text = media(pOH(1000))

For i As Integer = 0 To (ListBox1.Items.Count() - 1)
DS(H(1000)) = DS(H(1000)) + (media(H(1000)) - H(i)) ^ 2
DS(pH(1000)) = DS(pH(1000)) + (media(pH(1000)) - pH(i)) ^ 2
DS(pOH(1000)) = DS(pOH(1000)) + (media(pOH(1000)) - pOH(i)) ^ 2
Next (i)
DS(H(1000)) = (DS(H(1000)) / (ListBox1.Items.Count() - 1)) ^ 0.5
DS(pH(1000)) = (DS(pH(1000)) / (ListBox1.Items.Count() - 1)) ^ 0.5
DS(pOH(1000)) = (DS(pOH(1000)) / (ListBox1.Items.Count() - 1)) ^ 0.5
TextBox5.Text = DS(H(1000))
TextBox6.Text = DS(pH(1000))
TextBox7.Text = DS(pOH(1000))
End Sub

Private Sub Button5_Click(
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
ListBox1.Items.Clear()
ListBox2.Items.Clear()
ListBox3.Items.Clear()
For i As Integer = 0 To (1000)
H(i) = 0
pH(i) = 0
pOH(i) = 0
Next (i)
TextBox1.Focus()
End Sub

Private Sub Button6_Click(
End
End Sub
End Class

USO DE FUNCIONES

Public Class Form1
Dim Ndatos As Integer
Dim Tc As Single
Dim Pc As Single
Dim V(1000) As Single
Dim T(1000) As Single
Dim P(1000) As Single
Dim medV As Single
Dim medT As Single
Dim medP As Single
Dim dsV As Single
Dim dsT As Single
Dim dsP As Single
Dim A As Single
Dim B As Single
Dim i As Single
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Ndatos = Val(TextBox1.Text)
For i As Integer = 0 To Ndatos - 1
V(i) = Val(InputBox("Ingrese [V]" & i + 1))
ListBox1.Items.Add(V(i))
Next i
For i As Integer = 0 To Ndatos - 1
T(i) = Val(InputBox("Ingrese [T]" & i + 1))
ListBox2.Items.Add(T(i))
Next i
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Tc = Val(TextBox2.Text)
Pc = Val(TextBox3.Text)
A = 27 * (0.08205 ^ 2) * (Tc ^ 2) / (64 * Pc)
B = 0.08205 * Tc / (8 * Pc)
For i As Integer = 0 To Ndatos - 1
P(i) = 0.08205 * T(i) / (V(i) - B) - A / V(i) ^ 2
ListBox3.Items.Add(P(i))
Next i
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
medV = 0
medT = 0
medP = 0
dsV = 0
dsT = 0
dsP = 0
For i As Integer = 0 To Ndatos - 1
medV = medV + V(i)
medT = medT + T(i)
medP = medP + P(i)
Next i
medV = medV / Ndatos
medT = medT / Ndatos
medP = medP / Ndatos
TextBox4.Text = medV
TextBox5.Text = medT
TextBox6.Text = medP
For i As Integer = 0 To Ndatos - 1
dsV = dsV + (V(i) - medV) ^ 2
dsT = dsT + (T(i) - medV) ^ 2
dsP = dsP + (P(i) - medV) ^ 2
Next i
dsV = (dsV / Ndatos) ^ 0.5
dsT = (dsT / Ndatos) ^ 0.5
dsP = (dsP / Ndatos) ^ 0.5
TextBox7.Text = dsV
TextBox8.Text = dsT
TextBox9.Text = dsP
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""
TextBox9.Text = ""
ListBox1.Items.Clear()
ListBox2.Items.Clear()
ListBox3.Items.Clear()
For i As Integer = 0 To Ndatos - 1
V(i) = 0
T(i) = 0
P(i) = 0
Next i
TextBox1.Focus()
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button5.Click
End
End Sub
End Class

You might also like