Codigo Programacion
Codigo Programacion
Public Class Form1 Sub pmdg() Dim pm(5), fm(5), norm(5), npm(5), sfm, snpm, pma, dg, ge As Single Dim i As Integer If rbge.Checked = True Then ge = CSng(InputBox("introducir GE", "PM Y DG", "")) pma = ge * 28.97 dg = ge * 8.33 Else If rbfm.Checked = True Then sfm = 0 For i = 1 To 5 fm(i) = CSng(InputBox("int.fm del c" + CStr(i), "PM Y DG", "")) pm(i) = CSng(InputBox("int. pm del c" + CStr(i), "PM Y DG", "")) sfm = sfm + fm(i) Next If sfm = 1 Then For i = 1 To 5 norm(i) = fm(i) Next Else For i = 1 To 5 norm(i) = fm(i) / sfm Next End If Else MsgBox("Error seleccione una opcion") End If snpm = 0 For i = 1 To 5 npm(i) = norm(i) * pm(i) snpm = snpm + npm(i) Next pma = snpm dg = (pma / 28.97) * 8.33 End If lblpma.Text = "Peso Molecular Aparente =" + CStr(pma) lbldg.Text = "Densidad del Gas =" + CStr(dg) End Sub Private Sub btncal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncal.Click Call pmdg() End Sub End Class
Pregunta 2
Public Class Form1 Sub toneladamilla() Dim ws1, ws2, h1, h2, wc, tm As Single Dim top, op As String ws1 = CSng(txtws1.Text) ws2 = CSng(txtws2.Text) h1 = CSng(txth1.Text) h2 = CSng(txth2.Text)
wc = CSng(txtwc.Text) top = txttop.Text Select Case top Case "VR" tm = 2 * ws1 * h1 op = "TM viaje redondo =" Case "P" tm = 2 * (2 * ws2 * h2 - 2 * ws1 * h1) op = "TM perforacin =" Case "BC" tm = 2 * wc * h1 op = "TM bajada de caeria=" Case Else MsgBox("error introdusca un tipo de operacion") End Select lbltm.Text = op + CStr(tm) End Sub Private Sub btncal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncal.Click Call toneladamilla() End Sub End Class
Pregunta 3
Public Class Form1 Sub velocidad() Dim v, q, dma, dme, id As Single 'Dim s As Integer Dim s As String q = CSng(InputBox("caudal(BPM)", "INTRODUCIR DATO", "")) 's = Val(InputBox("Seccin; EA=1; IS=2", "INTRODUCIR DATO", "")) s = InputBox("Seccin; EA; IS", "INTRODUCIR DATO", "") If s = "EA" Then dma = CSng(InputBox("Dimetro mayor (pulg)", "INTODUCIR DATO", "")) dme = CSng(InputBox("diametro menor(pulg)", "INTRODUCIR DATO", "")) v = q / (((dma ^ 2 - dme ^ 2) / 1029.4) * 60) Else If s = "IS" Then id = CSng(InputBox("diametro interno(pulg)", " INTRODUCIR DATO", "")) v = q / ((id ^ 2 / 1029.4) * 60) Else MsgBox("Error intorsca un opcin vlida]") End If End If lblv.Text = CStr(v) + "ft/seg" End Sub Private Sub btncal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncal.Click Call velocidad() End Sub End Class
lblpma.Text = "Peso molecular aparente=" + CStr(pma) End Sub Private Sub btncal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncal.Click 'Call pmdg() Call pmdgselect() End Sub End Class
Pregunta 2
Public Class Form1 Sub toneladamilla() Dim tm, ws1, ws2, h1, h2, wc As Single Dim op As String ws1 = CSng(txtws1.Text) ws2 = CSng(txtws2.Text) h1 = CSng(txth1.Text) h2 = CSng(txth2.Text) wc = CSng(txtwc.Text) If rbvr.Checked = True Then tm = 2 * ws1 * h1 op = "TM viaje redondo=" + CStr(tm) Else If rbp.Checked = True Then tm = 2 * (2 * ws2 * h2 - 2 * ws1 * h1) op = "TM perforacion=" + CStr(tm) Else If rbbc.Checked = True Then tm = wc * h1 op = "TM bajada de caeria=" + CStr(tm) Else op = "error seleccione una opcion" End If End If End If lbltm.Text = op End Sub Private Sub btncal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncal.Click Call toneladamilla() End Sub End Class
Pregunta 3
Public Class Form1 Sub velocidad() Dim v, q, id, dma, dme As Single Dim s As String q = CSng(InputBox("introducir caudal", " calculo de velocidades de flujo", "")) s = InputBox("introducir seccion: espacio anular= EA, interior de la sarta=IS", "calculo de velocidades de flujo", "") Select Case s Case "EA" dma = CSng(InputBox("introducir diametro mayor", "calculo de velocidades de flujo", ""))
dme = CSng(InputBox("introducir diametro menor", "calculo de velocidades de flujo", "")) v = q / ((3.1416 / 4) * (dma ^ 2 - dme ^ 2)) Case "IS" id = CSng(InputBox("introducir diametro interno", "calculo de velocidades de flujo", "")) v = q / ((3.1416 / 4) * id ^ 2) Case Else MsgBox("error introdusca una seccion") End Select lblvf.Text = "Velocidad de flujo (ft/seg)=" + CStr(v) lbls.Text = s End Sub
Private Sub btncal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncal.Click Call velocidad() End Sub End Class
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 Preguntas de examen 1er parcial de la hoja de ayudantias de Erick son 20 preguntas Pregunta 1
Public Class Form1 '1era pregunta Sub temperatura() '2da forma sin introducir las columnas presion y temperatura Dim h, tc, ta, gradt, prof As Single Dim n, i As Integer ta = CSng(InputBox("Temp. Ambiente", "INTRODUCIR DATO", "")) prof = CSng(InputBox("Profundiad Total", "INTRODUCIR DATO")) n = Math.Abs(prof / 100) dg2.ColumnCount = 2 dg2.RowCount = n + 2 dg2.Item(0, 0).Value = "Profundidad" dg2.Item(1, 0).Value = "Temperatura" gradt = 1 / 30 h = 0 For i = 1 To n + 1 tc = h * gradt + ta dg2.Item(0, i).Value = h dg2.Item(1, i).Value = tc h = h + 100 Next End Sub 'primera forma introduciendo manualmente las columnas presion y temperatura Private Sub btncal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncal.Click Dim h, tc, ta, prof As Single Const gradt As Single = 1 / 30 Dim n, i As Integer prof = CSng(txtpt.Text) ta = CSng(txtta.Text) n = prof / 100 dgtc.ColumnCount = 2 dgtc.RowCount = n + 1 h = 0 For i = 0 To n tc = h * gradt + ta dgtc.Item(0, i).Value = h dgtc.Item(1, i).Value = tc h = h + 100 Next End Sub 'parte de la 2da forma Private Sub btn2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn2.Click Call temperatura() End Sub '3era forma Dim ta, prof, tc(), p() As Single Dim n, i As Integer Sub temfondo()
ta = CSng(InputBox("Temp. Ambiente", "INTRODUCIR DATO", "")) prof = CSng(InputBox("Profundiad Total", "INTRODUCIR DATO")) n = prof / 100 dgtc.ColumnCount = 2 dgtc.RowCount = n + 1 ReDim tc(n), p(n) For i = 0 To n p(i) = i * 100 tc(i) = ta + (1 / 30) * p(i) dgtc.Item(0, i).Value = p(i) dgtc.Item(1, i).Value = tc(i) Next End Sub Sub limpiar() For i = 0 To n dgtc.Item(1, i).Value = "" dgtc.Item(0, i).Value = "" Next End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Call temfondo() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Call limpiar() End Sub 'otra forma Sub otraforma() Dim tc, ta, prof As Single Dim n, i, h As Integer ta = CSng(InputBox("Temp. Ambiente", "INTRODUCIR DATO", "")) prof = CSng(InputBox("Profundiad Total", "INTRODUCIR DATO")) n = prof / 100 dgtc.ColumnCount = 2 dgtc.RowCount = n + 1 h = 0 For i = 0 To prof Step 100 tc = i * (1 / 30) + ta dgtc.Item(0, h).Value = i dgtc.Item(1, h).Value = tc h = h + 1 Next End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Call otraforma() End Sub End Class
Pregunta 2
Public Class Form1 Sub gradientedeformacion() Dim pf, prof, dl, gradf, ph As Single pf = CSng(txtpf.Text) prof = CSng(txtprof.Text) dl = CSng(txtdl.Text)
'pf = CSng(InputBox("introducir PF", "GRADF", "")) 'prof = CSng(InputBox("introducir Prof", "GRADF", "")) 'dl = CSng(InputBox("introducir DL", "GRADF", "")) ph = dl * prof gradf = pf / prof ' If gradf > 0.465 Then 'lblgradf.Text = "anormal" 'Else 'If gradf < 0.433 Then 'lblgradf.Text = "subnormal" 'Else 'lblgradf.Text = "normal" 'End If 'End If 'If ph > pf Then 'lbldp.Text = "sobre balanceada" 'Else 'If ph < pf Then ' lbldp.Text = "sub balanceada" 'Else 'lbldp.Text = "balanceada" 'End If 'End If Select Case gradf Case Is > 0.465 lblgradf.Text = "anormal" Case Is < 0.433 lblgradf.Text = "subnormal" Case 0.433 To 0.465 lblgradf.Text = "normal" End Select lblgrad.Text = CStr(gradf) ' lblph.Text = CStr(ph) 'txtpf.Text = CStr(pf) 'txtprof.Text = CStr(prof) 'txtdl.Text = CStr(dl)
End Sub Sub inicio() txtpf.Text = InputBox("introducir PF", "GRADF", "") txtprof.Text = InputBox("introducir Prof", "GRADF", "") txtdl.Text = InputBox("introducir DL", "GRADF", "") ' Dim pf, prof, dl As Single 'pf = CSng(InputBox("introducir PF", "GRADF", "")) 'prof = CSng(InputBox("introducir Prof", "GRADF", "")) 'dl = CSng(InputBox("introducir DL", "GRADF", "")) 'txtpf.Text = CStr(pf) 'txtprof.Text = CStr(prof) 'txtdl.Text = CStr(dl) End Sub Sub borrar() lblgrad.Text = "" lblph.Text = "" txtpf.Text = "" txtprof.Text = "" txtdl.Text = "" lblgradf.Text = "" lbldp.Text = ""
End Sub Private Sub calcular_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calcular.Click Call gradientedeformacion() End Sub Private Sub iniciar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles iniciar.Click Call inicio() End Sub Private Sub limpiar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles limpiar.Click Call borrar() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click End End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub End Class
Pregunta 3
Public Class Form1 Dim gradf(), gradfr(), prof(), ph(), pf(), pfr(), dl As Single Dim i, n As Integer Dim pc As String Private Sub btncal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncal.Click n = CInt(InputBox("N de profunidades a analizar", "INTODUCIR DATO", "")) dl = CSng(InputBox("Densidad del lodo(ppg)", "INTRODUCIR DATO", "")) dgpc.ColumnCount = 5 dgpc.RowCount = n ReDim gradf(n - 1), gradfr(n - 1), prof(n - 1), ph(n - 1), pf(n - 1), pfr(n - 1) For i = 0 To n - 1 prof(i) = CSng(InputBox("Profunidad(pie)" + CStr(i + 1), "INTRODUCIR DATO", "")) gradf(i) = CSng(InputBox("gradiente de form(psi/pie)" + CStr(i + 1), "INTRODUCIR DATO", "")) gradfr(i) = CSng(InputBox("gradiente de fract(psi/pie)" + CStr(i + 1), "INTRODUCIR DATO", "")) ph(i) = 0.052 * dl * prof(i) pf(i) = gradf(i) * prof(i) pfr(i) = gradfr(i) * prof(i) Select Case ph(i) Case Is > pf(i) pc = "perdida de circulacion" Case Is < pf(i) pc = "influjo" Case Is > pf(i) And ph(i) < pfr(i) pc = "estable" End Select dgpc.Item(0, i).Value = prof(i) dgpc.Item(1, i).Value = ph(i) dgpc.Item(2, i).Value = pf(i)
dgpc.Item(3, i).Value = pfr(i) dgpc.Item(4, i).Value = pc Next End Sub End Class
Pregunta 4
Public Class Form1 'pregunta 4 Dim fm(6), pm(6), norm(6), npm(6) As Single 'parte de la 2da forma usando funciones Public Function sumar(ByVal i As Integer, ByVal n As Integer) Dim s As Single s = 0 For i = 0 To n s = s + fm(i) Next Return (s) End Function 'esto pa las dos formas Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load gdge.ColumnCount = 5 gdge.RowCount = 7 For i = 0 To 6 gdge.Item(0, i).Value = "c" + CStr(i + 1) Next For i = 0 To 5 gdge.Item(3, i).Value = CStr(12 * (i + 1) + 2 * (i + 1) + 2) Next End Sub 'hasta aqui 'primera forma Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim pma, geg, pmc7, sfm, snpm As Single Dim i As Integer sfm = 0 For i = 0 To 6 fm(i) = CSng(InputBox("Fm del C " + CStr(i + 1), "Int. Dato", "")) gdge.Item(1, i).Value = fm(i) sfm = sfm + fm(i) Next Select Case sfm Case Is = 1 For i = 0 To 6 norm(i) = fm(i) gdge.Item(2, i).Value = norm(i) Next Case Is <> 1 And sfm > 0 For i = 0 To 6 norm(i) = fm(i) / sfm gdge.Item(2, i).Value = norm(i) Next Case Else MsgBox("introdusca bien los datos") End Select pmc7 = CSng(InputBox("PM del C7", "introducir dato", "")) gdge.Item(3, 6).Value = pmc7 snpm = 0
For i = 0 To 6 pm(i) = CSng(gdge.Item(3, i).Value) npm(i) = norm(i) * pm(i) gdge.Item(4, i).Value = npm(i) snpm = snpm + npm(i) Next pma = snpm geg = pma / 28.97 lblpma.Text = "Peso molecular (lb/mol) = " + CStr(pma) lblgeg.Text = "Gravedad Especifica del Gas = " + CStr(geg) End Sub 'segunda forma Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim pma, geg, pmc7, sfm, snpm As Single Dim i As Integer For i = 0 To 6 fm(i) = CSng(InputBox("Fm del C " + CStr(i + 1), "Int. Dato", "")) gdge.Item(1, i).Value = fm(i) Next sfm = sumar(0, 6) Select Case sfm Case Is = 1 For i = 0 To 6 norm(i) = fm(i) gdge.Item(2, i).Value = norm(i) Next Case Is <> 1 And sfm > 0 For i = 0 To 6 norm(i) = fm(i) / sfm gdge.Item(2, i).Value = norm(i) Next Case Else MsgBox("introdusca bien los datos") End Select pmc7 = CSng(InputBox("PM del C7", "introducir dato", "")) gdge.Item(3, 6).Value = pmc7 snpm = 0 For i = 0 To 6 pm(i) = CSng(gdge.Item(3, i).Value) npm(i) = norm(i) * pm(i) gdge.Item(4, i).Value = npm(i) snpm = snpm + npm(i) Next pma = snpm geg = pma / 28.97 lblpma.Text = "Peso molecular (lb/mol) = " + CStr(pma) lblgeg.Text = "Gravedad Especifica del Gas = " + CStr(geg) End Sub End Class
Pregunta 5
Public Class Form1 'primera forma Private Sub btncal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncal.Click Dim q, vem, dc, lc, ef, vd As Single Dim i, n As Integer n = (60 - 5) / 5 dgcv.ColumnCount = 2 dgcv.RowCount = n + 1 dc = CSng(InputBox("Diametro de camisa", "intr. dato", "")) lc = CSng(InputBox("Longitud de camisa", "intr. dato", ""))
ef = CSng(InputBox("Eficiencia de la bomba", "intr. dato", "")) vd = (3.1416 / 4) * dc ^ 2 * ef * lc * 3 vem = 5 For i = 0 To n q = vd * vem dgcv.Item(0, i).Value = vem dgcv.Item(1, i).Value = q vem = vem + 5 Next End Sub 'segunda forma Private Sub btncal2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncal2.Click Dim q, vem, dc, lc, ef, vd As Single Dim n, i As Integer n = (60 - 5) / 5 dgcv.ColumnCount = 2 dgcv.RowCount = n + 1 dc = CSng(InputBox("Diametro de camisa", "intr. dato", "")) lc = CSng(InputBox("Longitud de camisa", "intr. dato", "")) ef = CSng(InputBox("Eficiencia de la bomba", "intr. dato", "")) vd = (3.1416 / 4) * dc ^ 2 * ef * lc * 3 i = 0 For vem = 5 To 60 Step 5 q = vem * vd dgcv.Item(0, i).Value = vem dgcv.Item(1, i).Value = q i = i + 1 Next End Sub 'tercera forma utilizando variables dinamicas Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim vem(), q(), dc, lc, ef, vd As Single Dim n, i As Integer n = (60 - 5) / 5 dgcv.ColumnCount = 2 dgcv.RowCount = n + 1 dc = CSng(InputBox("Diametro de camisa", "intr. dato", "")) lc = CSng(InputBox("Longitud de camisa", "intr. dato", "")) ef = CSng(InputBox("Eficiencia de la bomba", "intr. dato", "")) vd = (3.1416 / 4) * dc ^ 2 * ef * lc * 3 ReDim vem(n), q(n) For i = 0 To n vem(i) = (i + 1) * 5 q(i) = vd * vem(i) dgcv.Item(0, i).Value = vem(i) dgcv.Item(1, i).Value = q(i) Next End Sub End Class PREGUNTA 6 Public Class Form1 Dim dl(), prof() As Single Private Sub btncal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncal.Click Dim we, wc, proft, int, swe As Single Dim n, i, d, j As Integer proft = CSng(InputBox("prof. total", "intr. dato", "")) int = CSng(InputBox("intervalo de profundiad", "intr. dato", ""))
d = CInt(InputBox("numero de lodo", "intr. dato", "")) n = proft / int dgwe.ColumnCount = d + 1 dgwe.RowCount = n + 1 dgwe.Item(0, 0).Value = "PROFUNDIDAD PIE" wc = CSng(InputBox("peso de la caeria", "intr. dato", "")) ReDim dl(d - 1), prof(n - 1) swe = 0 For j = 0 To d - 1 dl(j) = CSng(InputBox("densidad del lodo N " + CStr(j + 1), "intr. dato", "")) dgwe.Item(j + 1, 0).Value = "Densidad= " + CStr(dl(j)) + " ppg" For i = 0 To n - 1 prof(i) = int * (i + 1) dgwe.Item(0, i + 1).Value = CStr(prof(i)) we = prof(i) * Math.Cos(60 / 3.1416) * wc * (1 - dl(j) / 65.5) dgwe.Item(j + 1, i + 1).Value = CStr(we) swe = swe + we Next Next lblwet.Text = "peso total de la sata= " + CStr(swe) + " lbs" End Sub End Class PREGUNTA 7 Public Class Form1 Dim vr(), z() As Single 'primera forma con funcion sumaz Public Function sumaz(ByVal i As Integer, ByVal n As Integer) Dim sz As Single sz = 0 For i = 0 To n sz = sz + z(i) Next Return (sz) End Function Private Sub btncal1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncal1.Click Dim p, t, sz, zp, vi As Single Dim i, n As Integer n = CInt(InputBox("N de volumenes de gas real", "intr. dato", "")) dgzp.ColumnCount = 2 dgzp.RowCount = n p = CSng(InputBox("presion del gas (psi)", "intr. dato", "")) t = CSng(InputBox("temp. del gas (R)", "intr. dato", "")) vi = 10.78 * (t / p) ReDim vr(n - 1), z(n - 1) For i = 0 To n - 1 vr(i) = CSng(InputBox("V.real N " + CStr(i + 1), "intr. dato", "")) dgzp.Item(0, i).Value = CStr(vr(i)) z(i) = vr(i) / vi dgzp.Item(1, i).Value = CStr(z(i)) Next sz = sumaz(0, n - 1) zp = sz / n lblzp.Text = "Z promedio= " + CStr(zp) End Sub 'segunda forma sin utilizar funcion Private Sub btncal2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncal2.Click Dim p, t, sz, zp, vi As Single Dim i, n As Integer n = CInt(InputBox("N de volumenes de gas real", "intr. dato", "")) dgzp.ColumnCount = 2
dgzp.RowCount = n p = CSng(InputBox("presion del gas (psi)", "intr. dato", "")) t = CSng(InputBox("temp. del gas (R)", "intr. dato", "")) vi = 10.78 * (t / p) ReDim vr(n - 1), z(n - 1) sz = 0 For i = 0 To n - 1 vr(i) = CSng(InputBox("V.real N " + CStr(i + 1), "intr. dato", "")) dgzp.Item(0, i).Value = CStr(vr(i)) z(i) = vr(i) / vi dgzp.Item(1, i).Value = CStr(z(i)) sz = sz + z(i) Next zp = sz / n lblzp.Text = "Z promedio= " + CStr(zp) End Sub End Class PREGUNTA 8 Public Class Form1 Dim nom(), cat() As String Dim hb(), tg() As Single Private Sub btncal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncal.Click Dim i, n As Integer n = CInt(InputBox("N de datos", "intr. datos", "")) dgtg.ColumnCount = 4 dgtg.RowCount = n ReDim nom(n - 1), cat(n - 1), hb(n - 1), tg(n - 1) For i = 0 To n - 1 nom(i) = InputBox("Nombre N " + CStr(i + 1), "intr. dato", "") dgtg.Item(0, i).Value = nom(i) cat(i) = InputBox("Categoria A, B C", "intr. dato", "") dgtg.Item(1, i).Value = cat(i) hb(i) = CSng(InputBox("haber basico", "intr. dato", "")) dgtg.Item(2, i).Value = CStr(hb(i)) If Not hb(i) > 5000 Then Select Case cat(i) Case "A" tg(i) = hb(i) * 1.05 dgtg.Item(3, i).Value = CStr(tg(i)) Case "B" tg(i) = hb(i) * 1.1 dgtg.Item(3, i).Value = CStr(tg(i)) Case "C" tg(i) = hb(i) * 1.2 dgtg.Item(3, i).Value = CStr(tg(i)) Case Else dgtg.Item(3, i).Value = "introdusca una categoria valida" End Select Else If (cat(i) = "A") Or (cat(i) = "B") Or (cat(i) = "C") Then tg(i) = hb(i) dgtg.Item(3, i).Value = CStr(tg(i)) Else dgtg.Item(3, i).Value = "introdusca una categoria valida" End If End If Next End Sub End Class PREGUNTA 9
Private Sub btncal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncal.Click Dim dg, t0, p0, h, pm, proft, int As Single Dim n, i As Integer proft = CSng(InputBox("Prof. total", "Intr. Dato", "")) int = CSng(InputBox("Intervalo de prof", "Intr. Dato", "")) n = proft / int dgdg.ColumnCount = 2 dgdg.RowCount = n + 1 '---->comenzando la profundidad desde cero pm = CSng(InputBox("Peso Molecular del Gas", "Intr. Dato", "")) p0 = CSng(InputBox("Pesion Po", "Intr. Dato", "")) t0 = CSng(InputBox("Temp. To", "Intr. Dato", "")) h = 0 For i = 0 To n dg = (10.7 * (t0 + 0.033 * h)) / (pm * (p0 + 0.3 * h)) dgdg.Item(0, i).Value = CStr(h) dgdg.Item(1, i).Value = CStr(dg) h = h + int Next End Sub End Class PREGUNTA 10 Public Class Form1 Dim al() As String Dim nota() As Single Private Sub btncal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncal.Click Dim pna, pnr, sna, snr As Single Dim obs As String Dim n, i, j, k As Integer n = CInt(InputBox("N de Alumnos", "INTRODUCIR DATO", "")) dgpn.ColumnCount = 4 dgpn.RowCount = n ReDim al(n - 1), nota(n - 1) j = 0 k = 0 sna = 0 snr = 0 For i = 0 To n - 1 dgpn.Item(0, i).Value = CStr(i + 1) al(i) = InputBox("Nombre del Alumno N " + CStr(i + 1), "INTRODUCIR DATO", "") dgpn.Item(1, i).Value = al(i) nota(i) = CSng(InputBox("Nota del Alumno N " + CStr(i + 1), "INTRODUCIR DATO", "")) dgpn.Item(2, i).Value = CStr(nota(i)) Select Case nota(i) Case Is >= 51 obs = "Aprobado" sna = sna + nota(i) j = j + 1 Case 0 To 50 obs = "Reprobado" snr = snr + nota(i) k = k + 1 Case Else obs = ("Error Introducir nota correcta") End Select dgpn.Item(3, i).Value = obs Next pna = sna / j
pnr = snr / lblpna.Text lblcaa.Text lblpnr.Text lblcar.Text End Sub End Class PREGUNTA 11 Public Class Form1
k = = = =
de de de de
Notas de Alumnos Aprobados= " + CStr(pna) Alumnos Aprobados= " + CStr(j) Notas de Alumnos Reprobados= " + CStr(pnr) Alumnos Reprobados= " + CStr(k)
Private Sub btncal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncal.Click Dim ph, proft, intp, d, h As Single Dim c, f, i, j As Integer c = (12 - 8.5) / 0.5 proft = CSng(InputBox("prof. total", "intr. Dato", "")) intp = CSng(InputBox("intervalo de profundidad", "intr. Dato", "")) f = proft / intp dgph.ColumnCount = c + 2 dgph.RowCount = f + 1 dgph.Item(0, 0).Value = "Profundidad (ft)" For i = 0 To c d = 8.5 + i * 0.5 dgph.Item(i + 1, 0).Value = "Densidad= " + CStr(d) + " ppg" h = intp For j = 0 To f - 1 dgph.Item(0, j + 1).Value = CStr(h) ph = 0.052 * d * h dgph.Item(i + 1, j + 1).Value = CStr(ph) h = h + intp Next Next End Sub End Class PREGUNTA 12 Public Class Form1 Sub calculorumbo() Dim rumbo, azimut As Single azimut = CSng(txtaz.Text) If azimut >= 0 And azimut <= 90 Then rumbo = azimut lblpo.Text = "Nor-Este" Else If azimut >= 0 And azimut <= 180 Then rumbo = 180 - azimut lblpo.Text = "Sur-este" Else If azimut >= 0 And azimut <= 270 Then rumbo = azimut - 180 lblpo.Text = "Sur-Oeste" Else If azimut >= 0 And azimut <= 360 Then rumbo = 360 - azimut lblpo.Text = "Nor-Oeste" Else MsgBox("error") End If
End If End If End If lblrb.Text = CStr(rumbo) End Sub Sub rumboselectcase() Dim rumbo, azimut As Single azimut = CSng(txtaz.Text) Select Case azimut Case 0 To 90 rumbo = azimut lblpo.Text = "nor-este" Case 91 To 180 rumbo = 180 - azimut lblpo.Text = "sur-este" Case 181 To 270 rumbo = azimut - 180 lblpo.Text = "sur-oeste" Case 271 To 360 rumbo = 360 - azimut lblpo.Text = "nor-oeste" Case Else MsgBox("error") End Select lblrb.Text = CStr(rumbo) End Sub 'no corre correctamente no utilizar Sub rumboselectcaseand() Dim rumbo, azimut As Single azimut = CSng(txtaz.Text) Select Case azimut Case Is >= 0 And azimut <= 90 rumbo = azimut lblpo.Text = "nor-este" Case Is >= 91 And azimut <= 180 rumbo = 180 - azimut lblpo.Text = "sur-este" Case Is >= 181 And azimut <= 270 rumbo = azimut - 180 lblpo.Text = "sur-oeste" Case Is >= 271 And azimut <= 360 rumbo = 360 - azimut lblpo.Text = "nor-oeste" Case Else MsgBox("error") End Select lblrb.Text = CStr(rumbo) End Sub Sub borrar() lblpo.Text = "" lblrb.Text = "" txtaz.Text = "" End Sub Private Sub btncal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncal.Click 'Call calculorumbo() Call rumboselectcase() End Sub Private Sub btnlim_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlim.Click Call borrar() End Sub
Private Sub btnsa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsa.Click End End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub End Class PREGUNTA 14 Public Class Form1 Dim h(), pf() As Single Private Sub btncal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncal.Click Dim gradf As Single Dim cla As String Dim i, n As Integer n = CInt(InputBox("N de datos", "INTR. DATO", "")) dggc.ColumnCount = 4 dggc.RowCount = n ReDim h(n - 1), pf(n - 1) For i = 0 To n - 1 h(i) = CSng(InputBox("PROFUNDIDAD N" + CStr(i + 1), "INTR. DATO", "")) dggc.Item(0, i).Value = CStr(h(i)) pf(i) = CSng(InputBox("presion de formacion a la prof. " + CStr(i + 1), "INTR. DATO", "")) dggc.Item(1, i).Value = CStr(pf(i)) gradf = pf(i) / h(i) dggc.Item(2, i).Value = CStr(gradf) If gradf >= 0 And gradf < 0.2 Then cla = "bajo" Else If gradf >= 0.2 And gradf < 0.4 Then cla = "madio" Else If gradf >= 0.4 And gradf < 1 Then cla = "alto" Else If gradf >= 1 Then cla = "muy alto" Else cla = "INTRODUSCA VALORES POSITIVOS" End If End If End If End If dggc.Item(3, i).Value = cla Next End Sub Private Sub btncal2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncal2.Click Dim gradf As Single Dim cla As String Dim i, n As Integer n = CInt(InputBox("N de datos", "INTR. DATO", "")) dggc.ColumnCount = 4 dggc.RowCount = n + 1 dggc.Item(0, 0).Value = "profundidad" dggc.Item(1, 0).Value = "pf" dggc.Item(2, 0).Value = "gradf"
dggc.Item(3, 0).Value = "clasificacion" ReDim h(n - 1), pf(n - 1) For i = 0 To n - 1 h(i) = CSng(InputBox("PROFUNDIDAD N" + CStr(i + 1), "INTR. DATO", "")) dggc.Item(0, i + 1).Value = CStr(h(i)) pf(i) = CSng(InputBox("presion de formacion a la prof. " + CStr(i + 1), "INTR. DATO", "")) dggc.Item(1, i + 1).Value = CStr(pf(i)) gradf = pf(i) / h(i) dggc.Item(2, i + 1).Value = CStr(gradf) If gradf >= 0 And gradf < 0.2 Then cla = "bajo" Else If gradf >= 0.2 And gradf < 0.4 Then cla = "madio" Else If gradf >= 0.4 And gradf < 1 Then cla = "alto" Else If gradf >= 1 Then cla = "muy alto" Else cla = "INTRODUSCA VALORES POSITIVOS" End If End If End If End If dggc.Item(3, i + 1).Value = cla Next End Sub End Class PREGUNTA 16 Public Class Form1 Dim masa(), pm(), n(), fm() As Single Dim comp() As String Private Sub btncal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncal.Click Dim sn, sfm As Single Dim i, j As Integer j = CInt(InputBox("N de componentes", "Intr. Datos", "")) dgfm.ColumnCount = 5 dgfm.RowCount = j + 1 'PARA PONER A LO ULTIMO LA SUMA DE FM=SFM ReDim masa(j - 1), pm(j - 1), comp(j - 1), n(j - 1), fm(j - 1) i = 0 sn = 0 Do While i <= j - 1 comp(i) = InputBox("Componente N " + CStr(i + 1), "INTR. DATO", "") dgfm.Item(0, i).Value = comp(i) masa(i) = CSng(InputBox("masa en lbs de " + comp(i), "INTR. DATO", "")) dgfm.Item(1, i).Value = CStr(masa(i)) pm(i) = CSng(InputBox("peso molecualr en lb/mol de " + comp(i), "INTR. DATO", "")) dgfm.Item(2, i).Value = CStr(pm(i)) n(i) = masa(i) / pm(i) dgfm.Item(3, i).Value = CStr(n(i)) sn = sn + n(i) i = i + 1 Loop i = 0 sfm = 0 Do While i <= j - 1 fm(i) = n(i) / sn dgfm.Item(4, i).Value = CStr(fm(i))
sfm = sfm + fm(i) i = i + 1 Loop dgfm.Item(4, j).Value = "sfm= " + CStr(sfm) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim sn, sfm As Single Dim i, j As Integer j = CInt(InputBox("N de componentes", "Intr. Datos", "")) dgfm.ColumnCount = 5 dgfm.RowCount = j + 2 'PARA PONER A LO ULTIMO LA SUMA DE FM=SFM y nombre en las celdas dgfm.Item(0, 0).Value = "componente" dgfm.Item(1, 0).Value = "masa" dgfm.Item(2, 0).Value = "pm" dgfm.Item(3, 0).Value = "n" dgfm.Item(4, 0).Value = "fm" ReDim masa(j - 1), pm(j - 1), comp(j - 1), n(j - 1), fm(j - 1) i = 0 sn = 0 Do While i <= j - 1 comp(i) = InputBox("Componente N " + CStr(i + 1), "INTR. DATO", "") dgfm.Item(0, i + 1).Value = comp(i) masa(i) = CSng(InputBox("masa en lbs de " + comp(i), "INTR. DATO", "")) dgfm.Item(1, i + 1).Value = CStr(masa(i)) pm(i) = CSng(InputBox("peso molecualr en lb/mol de " + comp(i), "INTR. DATO", "")) dgfm.Item(2, i + 1).Value = CStr(pm(i)) n(i) = masa(i) / pm(i) dgfm.Item(3, i + 1).Value = CStr(n(i)) sn = sn + n(i) i = i + 1 Loop i = 0 sfm = 0 Do While i <= j - 1 fm(i) = n(i) / sn dgfm.Item(4, i + 1).Value = CStr(fm(i)) sfm = sfm + fm(i) i = i + 1 Loop dgfm.Item(4, j + 1).Value = "sfm= " + CStr(sfm) End Sub
End Class PREGUNTA 18 Public Class Form1 Dim tme() As Single Private Sub btncal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncal.Click Dim tma, tmr, tmax As Single Dim obs As String Dim i, n As Integer n = CInt(InputBox("N de operaciones", "INTR. DATO", )) tmax = Val(txttmax.Text) dgtm.ColumnCount = 5 dgtm.RowCount = n + 1 dgtm.Item(0, 0).Value = "Op. N" dgtm.Item(1, 0).Value = "TMefectiva" dgtm.Item(2, 0).Value = "TMacumulada"
dgtm.Item(3, 0).Value = "TMrestante" dgtm.Item(4, 0).Value = "Observacion" ReDim tme(n - 1) tma = 0 For i = 0 To n - 1 dgtm.Item(0, i + 1).Value = CStr(i + 1) tme(i) = CSng(InputBox("TM de op. N " + CStr(i + 1), "INTR. DATO", )) dgtm.Item(1, i + 1).Value = CStr(tme(i)) tma = tma + tme(i) dgtm.Item(2, i + 1).Value = CStr(tma) tmr = tmax - tma dgtm.Item(3, i + 1).Value = CStr(tmr) Select Case tma Case Is < tmax obs = "no cambiar cable" Case Else obs = "cambiar cable" End Select dgtm.Item(4, i + 1).Value = obs Next End Sub End Class PREGUNTA 19 Public Class Form1 'con variables matriciales dinamicas Dim v(), d() As Single Private Sub btncal1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncal1.Click Dim q, dma, dme, int As Single Dim n, i As Integer dma = CSng(InputBox("DM", "INTR. DATO", "")) dme = CSng(InputBox("Dm", "INTR. DATO", "")) int = CSng(InputBox("intervalo de cambio de diametro", "INTR. DATO", "")) n = (dma - dme) / int dgv.ColumnCount = 2 dgv.RowCount = n + 2 dgv.Item(0, 0).Value = "Diametro" dgv.Item(1, 0).Value = "velocidad" q = CSng(InputBox("caudal", "INTR. DATO", "")) ReDim v(n), d(n) For i = 0 To n d(i) = dme + int * i dgv.Item(0, i + 1).Value = CStr(d(i)) v(i) = q / ((301416 / 4) * d(i)) dgv.Item(1, i + 1).Value = CStr(v(i)) Next End Sub 'con varibles normales, sin variables dinamicas Private Sub btn2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn2.Click Dim q, dma, dme, int, ve, di As Single Dim n, i As Integer dma = CSng(InputBox("DM", "INTR. DATO", "")) dme = CSng(InputBox("Dm", "INTR. DATO", "")) int = CSng(InputBox("intervalo de cambio de diametro", "INTR. DATO", "")) n = (dma - dme) / int dgv.ColumnCount = 2 dgv.RowCount = n + 2 dgv.Item(0, 0).Value = "Diametro" dgv.Item(1, 0).Value = "velocidad" q = CSng(InputBox("caudal", "INTR. DATO", ""))
i = 0 For di = dme To dma Step int dgv.Item(0, i + 1).Value = CStr(di) ve = q / ((301416 / 4) * di) dgv.Item(1, i + 1).Value = CStr(ve) i = i + 1 Next End Sub 'otra forma Private Sub btncal3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncal3.Click Dim q, dma, dme, int, ve, di As Single Dim n, i As Integer dma = CSng(InputBox("DM", "INTR. DATO", "")) dme = CSng(InputBox("Dm", "INTR. DATO", "")) int = CSng(InputBox("intervalo de cambio de diametro", "INTR. DATO", "")) n = (dma - dme) / int dgv.ColumnCount = 2 dgv.RowCount = n + 2 dgv.Item(0, 0).Value = "Diametro" dgv.Item(1, 0).Value = "velocidad" q = CSng(InputBox("caudal", "INTR. DATO", "")) di = dme For i = 0 To n dgv.Item(0, i + 1).Value = CStr(di) ve = q / ((301416 / 4) * di) dgv.Item(1, i + 1).Value = CStr(ve) di = di + int Next End Sub End Class
PREGUNTA 20 Public Class Form1 Sub calcular1() Dim pg, h, prof, pf, dl As Single Dim i, n As Integer prof = (InputBox("Profundidad del pozo", "Intr. Dato", "")) n = prof / 100 'dice intervalos regulares, no dice indicar al programa el intervalo dgpf.ColumnCount = 2 dgpf.RowCount = n + 2 dgpf.Item(0, 0).Value = "Profundidad" dgpf.Item(1, 0).Value = "Presion de Fondo" dl = CSng(InputBox("Densidad del lodo", "INT. DATO", )) pg = CSng(InputBox("Presion de formacion", "INTR. DATO")) i = 0 For h = 0 To prof Step 100 dgpf.Item(0, i + 1).Value = CStr(prof - h) pf = pg + 0.052 * dl * h dgpf.Item(1, i + 1).Value = CStr(pf) i = i + 1 Next End Sub Sub calcular2() Dim pg, h, prof, pf, dl As Single Dim i, n As Integer prof = (InputBox("Profundidad del pozo", "Intr. Dato", "")) n = prof / 100 'dice intervalos regulares, no dice indicar al programa el intervalo dgpf.ColumnCount = 2 dgpf.RowCount = n + 2 dgpf.Item(0, 0).Value = "Profundidad"
End Sub
End Sub
End
dgpf.Item(1, 0).Value = "Presion de Fondo" dl = CSng(InputBox("Densidad del lodo", "INT. DATO", )) pg = CSng(InputBox("Presion de formacion", "INTR. DATO")) h = 0 For i = 0 To n dgpf.Item(0, i + 1).Value = CStr(prof - h) pf = pg + 0.052 * dl * h dgpf.Item(1, i + 1).Value = CStr(pf) h = h + 100 Next Sub calcular3() Dim pg, h, prof, pf, dl As Single Dim i, n As Integer prof = (InputBox("Profundidad del pozo", "Intr. Dato", "")) n = prof / 100 'dice intervalos regulares, no dice indicar al programa el intervalo dgpf.ColumnCount = 2 dgpf.RowCount = n + 2 dgpf.Item(0, 0).Value = "Profundidad" dgpf.Item(1, 0).Value = "Presion de Fondo" dl = CSng(InputBox("Densidad del lodo", "INT. DATO", )) pg = CSng(InputBox("Presion de formacion", "INTR. DATO")) h = 0 i = 0 Do While i <= n dgpf.Item(0, i + 1).Value = CStr(prof - h) pf = pg + 0.052 * dl * h dgpf.Item(1, i + 1).Value = CStr(pf) h = h + 100 i = i + 1 Loop Sub calcular4() Dim pg, h, prof, pf, dl As Single Dim i, n As Integer prof = (InputBox("Profundidad del pozo", "Intr. Dato", "")) n = prof / 100 'dice intervalos regulares, no dice indicar al programa el intervalo dgpf.ColumnCount = 2 dgpf.RowCount = n + 2 dgpf.Item(0, 0).Value = "Profundidad" dgpf.Item(1, 0).Value = "Presion de Fondo" dl = CSng(InputBox("Densidad del lodo", "INT. DATO", )) pg = CSng(InputBox("Presion de formacion", "INTR. DATO")) h = 0 i = 0 Do Until i > n dgpf.Item(0, i + 1).Value = CStr(prof - h) pf = pg + 0.052 * dl * h dgpf.Item(1, i + 1).Value = CStr(pf) h = h + 100 i = i + 1 Loop Sub
Private Sub btncal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncal.Click 'Call calcular1() 'Call calcular2() 'Call calcular3() Call calcular4() End Sub End Class