Código de Visual Basic - DataGridView

sin imagen de perfil
Val: 8
Ha disminuido su posición en 5 puestos en Visual Basic (en relación al último mes)
Gráfica de Visual Basic

DataGridViewgráfica de visualizaciones


Visual Basic

Publicado el 25 de Junio del 2018 por Luz
1.394 visualizaciones desde el 25 de Junio del 2018
ejemplo de datagridview con un botón.

Requerimientos

visual basic

3.33

Publicado el 25 de Junio del 2018gráfica de visualizaciones de la versión: 3.33
1.395 visualizaciones desde el 25 de Junio del 2018
estrellaestrellaestrellaestrellaestrella
estrellaestrellaestrellaestrella
estrellaestrellaestrella
estrellaestrella
estrella

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
Public Class Form3
    Public Sub New()
        InitializeComponent()
        Me.ComboBox2.Enabled = True
        Me.CONC_CO2.Enabled = True
        Me.CONC_O2.Enabled = True
        Me.CONC_N2.Enabled = True
        Me.Label7.Visible = True
        Me.Label8.Visible = True
        Me.Button_calcular.Enabled = True
 
 
    End Sub
 
 
 
    Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
 
 
        Dim row0 As String() = {"1", "CO2", "0.133", "44.01", "1462*10-7 g/cm*s"}
        Dim row1 As String() = {"2", "O2", "0.039", "32", "2031*10-7 g/cm*s"}
        Dim row2 As String() = {"3", "N2", "0.828", "28.02", "1754*10-7 g/cm*s"}
        With Me.DataGridView2.Rows
            .Add(row0)
            .Add(row1)
            .Add(row2)
        End With
 
 
 
        DataGridView1.Rows.Add()
        DataGridView1.Rows.Add()
        DataGridView1.Rows.Add()
        DataGridView1.Rows.Add()
        DataGridView1.Rows.Add()
        DataGridView1.Rows.Add()
        DataGridView1.Rows.Add()
        DataGridView1.Rows.Add()
        DataGridView1.Rows.Add()
        DataGridView1.Rows(0).Cells(0).Value = 1
        DataGridView1.Rows(0).Cells(1).Value = 1
        DataGridView1.Rows(1).Cells(0).Value = 1
        DataGridView1.Rows(1).Cells(1).Value = 2
        DataGridView1.Rows(2).Cells(0).Value = 1
        DataGridView1.Rows(2).Cells(1).Value = 3
 
        DataGridView1.Rows(3).Cells(0).Value = 2
        DataGridView1.Rows(3).Cells(1).Value = 1
        DataGridView1.Rows(4).Cells(0).Value = 2
        DataGridView1.Rows(4).Cells(1).Value = 2
        DataGridView1.Rows(5).Cells(0).Value = 2
        DataGridView1.Rows(5).Cells(1).Value = 3
 
        DataGridView1.Rows(6).Cells(0).Value = 3
        DataGridView1.Rows(6).Cells(1).Value = 1
        DataGridView1.Rows(7).Cells(0).Value = 3
        DataGridView1.Rows(7).Cells(1).Value = 2
        DataGridView1.Rows(8).Cells(0).Value = 3
        DataGridView1.Rows(8).Cells(1).Value = 3
 
 
    End Sub
 
    Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
 
        If ComboBox1.Text = "Atm" Then
 
            Label7.Text = Text_PRES.Text
        Else
            If ComboBox1.Text = "Pa" Then
 
                Label7.Text = Text_PRES.Text / 101325
 
            End If
            If Label7.Text < 1 Then
                MsgBox("Presión fuera del rango.", MsgBoxStyle.Information, "Viscosidad")
            ElseIf Label7.Text > 10 Then
                MsgBox("Presión fuera del rango.", MsgBoxStyle.Information, "Viscosidad")
 
            Else
                    If Text_PRES.Text = "" Then
                        MessageBox.Show("FALTAN DATOS", "INFORMACIÓN", MessageBoxButtons.OK, MessageBoxIcon.Information)
                        If Text_PRES.Text = "" Then
                            MsgBox("Introducir Valor a presión.", MsgBoxStyle.Information, "Viscosidad")
                        ElseIf ComboBox1.SelectedIndex = -1 Then
                            MsgBox("Seleccionar presión.", MsgBoxStyle.Information, "Viscosidad")
                        End If
 
                    End If
                End If
            End If
 
 
    End Sub
 
    Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged
 
        If ComboBox2.SelectedIndex = 0 Then
            Label8.Text = ((Text_TEM.Text + 459.47) * 5 / 9)
        ElseIf ComboBox2.SelectedIndex = 1 Then
            Label8.Text = (Text_TEM.Text + 273)
        ElseIf ComboBox2.SelectedIndex = 2 Then
            Label8.Text = (Text_TEM.Text)
        End If
 
        If Label8.Text < 0 And Label8.Text > 1000 Then
            MsgBox("Temperatura fuera del rango.", MsgBoxStyle.Information, "Viscosidad")
        Else
            If Convert.ToDouble(Label8.Text) < 0 Or Convert.ToDouble(Label8.Text) > 1000 Then
                MsgBox("Temperatura fuera del rango.", MsgBoxStyle.Information, "Viscosidad")
            ElseIf Text_TEM.Text = "" Then
                MsgBox("Introducir Valor a temperatura.", MsgBoxStyle.Information, "Viscosidad")
            ElseIf ComboBox2.SelectedIndex = -1 Then
                MsgBox("Seleccionar grados.", MsgBoxStyle.Information, "Viscosidad")
            ElseIf Text_TEM.Text = "" Then
            End If
 
        End If
 
    End Sub
 
    Private Sub Button_salir_Click(sender As Object, e As EventArgs) Handles Button_salir.Click
        If MsgBox("¿Desea salir de la aplicación?...", vbQuestion + vbYesNo, "") = vbYes Then
            End
        End If
    End Sub
 
    Private Sub Button_limpiar_Click(sender As Object, e As EventArgs) Handles Button_limpiar.Click
        ComboBox1.Text = ""
        ComboBox2.Text = ""
        Text_TEM.Text = ""
        Text_PRES.Text = ""
        CONC_CO2.Text = ""
        CONC_N2.Text = ""
        CONC_O2.Text = ""
        Label7.Text = ""
        Label8.Text = ""
        RES.Text = ""
 
        DataGridView1.Rows(0).Cells(2).Value = ""
        DataGridView1.Rows(1).Cells(2).Value = ""
        DataGridView1.Rows(2).Cells(2).Value = ""
        DataGridView1.Rows(3).Cells(2).Value = ""
        DataGridView1.Rows(4).Cells(2).Value = ""
        DataGridView1.Rows(5).Cells(2).Value = ""
        DataGridView1.Rows(6).Cells(2).Value = ""
        DataGridView1.Rows(7).Cells(2).Value = ""
        DataGridView1.Rows(8).Cells(2).Value = ""
 
        DataGridView1.Rows(0).Cells(3).Value = ""
        DataGridView1.Rows(1).Cells(3).Value = ""
        DataGridView1.Rows(2).Cells(3).Value = ""
        DataGridView1.Rows(3).Cells(3).Value = ""
        DataGridView1.Rows(4).Cells(3).Value = ""
        DataGridView1.Rows(5).Cells(3).Value = ""
        DataGridView1.Rows(6).Cells(3).Value = ""
        DataGridView1.Rows(7).Cells(3).Value = ""
        DataGridView1.Rows(8).Cells(3).Value = ""
 
        DataGridView1.Rows(0).Cells(4).Value = ""
        DataGridView1.Rows(1).Cells(4).Value = ""
        DataGridView1.Rows(2).Cells(4).Value = ""
        DataGridView1.Rows(3).Cells(4).Value = ""
        DataGridView1.Rows(4).Cells(4).Value = ""
        DataGridView1.Rows(5).Cells(4).Value = ""
        DataGridView1.Rows(6).Cells(4).Value = ""
        DataGridView1.Rows(7).Cells(4).Value = ""
        DataGridView1.Rows(8).Cells(4).Value = ""
 
        DataGridView1.Rows(1).Cells(5).Value = ""
        DataGridView1.Rows(4).Cells(5).Value = ""
        DataGridView1.Rows(7).Cells(5).Value = ""
 
 
 
    End Sub
 
    Private Sub Text_TEM_TextChanged(sender As Object, e As EventArgs) Handles Text_TEM.TextChanged
        If Text_TEM.Text = "" Then
            ComboBox2.Enabled = False
        Else
            ComboBox2.Enabled = True
 
 
        End If
 
    End Sub
    Private Sub Text_PRES_TextChanged(sender As Object, e As EventArgs) Handles Text_PRES.TextChanged
        Dim Numeros As String = "1234567890"
        If Text_PRES.Text = "" Then
            ComboBox1.Enabled = False
 
        Else
            ComboBox1.Enabled = True
 
 
        End If
        If ComboBox1.Text = "Atm" Then
 
            Label7.Text = Text_PRES.Text
        Else
            If ComboBox1.Text = "Pa" Then
 
                Label7.Text = Text_PRES.Text / 101325
            End If
 
 
 
 
        End If
    End Sub
 
    Private Sub Text_PRES_KeyPress(sender As Object, e As KeyPressEventArgs) Handles Text_PRES.KeyPress
        Dim Linea As String = Text_PRES.Text
        Dim Numeros As String = "1234567890"
        If Len(Linea) = 0 Then
            Numeros += "-"
        End If
        If Len(Linea) > 0 Then
            Numeros += "."
        End If
        For Each caracter In Numeros
            If e.KeyChar = caracter Then
                e.Handled = False
                Exit For
            Else
                e.Handled = True
            End If
        Next
        If e.KeyChar = "0" And Mid(Linea, 1, 1) = "0" And Len(Linea) = 1 Then
            Text_PRES.Text = ""
        ElseIf e.KeyChar <> "0" And e.KeyChar <> "." And Mid(Linea, 1, 1) = "0" And Len(Linea) = 1 Then
            Text_PRES.Text = ""
        End If
        If Char.IsControl(e.KeyChar) Then
            e.Handled = False
        End If
        If e.KeyChar = "." And Not Linea.IndexOf(".") Then
            e.Handled = True
        End If
 
    End Sub
 
    Private Sub Text_TEM_KeyPress(sender As Object, e As KeyPressEventArgs) Handles Text_TEM.KeyPress
        Dim Linea As String = Text_TEM.Text
        Dim Numeros As String = "1234567890"
        If Len(Linea) = 0 Then
            Numeros += "-"
        End If
        If Len(Linea) > 0 Then
            Numeros += "."
        End If
        For Each caracter In Numeros
            If e.KeyChar = caracter Then
                e.Handled = False
                Exit For
            Else
                e.Handled = True
            End If
        Next
        If e.KeyChar = "0" And Mid(Linea, 1, 1) = "0" And Len(Linea) = 1 Then
            Text_TEM.Text = ""
        ElseIf e.KeyChar <> "0" And e.KeyChar <> "." And Mid(Linea, 1, 1) = "0" And Len(Linea) = 1 Then
            Text_TEM.Text = ""
        End If
        If Char.IsControl(e.KeyChar) Then
            e.Handled = False
        End If
        If e.KeyChar = "." And Not Linea.IndexOf(".") Then
            e.Handled = True
        End If
    End Sub
 
    Private Sub CONC_CO2_KeyPress(sender As Object, e As KeyPressEventArgs) Handles CONC_CO2.KeyPress
        Dim Linea As String = CONC_CO2.Text
        Dim Numeros As String = "1234567890"
        If Len(Linea) = 0 Then
            Numeros += "-"
        End If
        If Len(Linea) > 0 Then
            Numeros += "."
        End If
        For Each caracter In Numeros
            If e.KeyChar = caracter Then
                e.Handled = False
                Exit For
            Else
                e.Handled = True
            End If
        Next
        If e.KeyChar = "0" And Mid(Linea, 1, 1) = "0" And Len(Linea) = 1 Then
            CONC_CO2.Text = ""
        ElseIf e.KeyChar <> "0" And e.KeyChar <> "." And Mid(Linea, 1, 1) = "0" And Len(Linea) = 1 Then
            CONC_CO2.Text = ""
        End If
        If Char.IsControl(e.KeyChar) Then
            e.Handled = False
        End If
        If e.KeyChar = "." And Not Linea.IndexOf(".") Then
            e.Handled = True
        End If
 
    End Sub
    Private Sub CONC_O2_KeyPress(sender As Object, e As KeyPressEventArgs) Handles CONC_O2.KeyPress
        Dim Linea As String = CONC_O2.Text
        Dim Numeros As String = "1234567890"
        If Len(Linea) = 0 Then
            Numeros += "-"
        End If
        If Len(Linea) > 0 Then
            Numeros += "."
        End If
        For Each caracter In Numeros
            If e.KeyChar = caracter Then
                e.Handled = False
                Exit For
            Else
                e.Handled = True
            End If
        Next
        If e.KeyChar = "0" And Mid(Linea, 1, 1) = "0" And Len(Linea) = 1 Then
            CONC_O2.Text = ""
        ElseIf e.KeyChar <> "0" And e.KeyChar <> "." And Mid(Linea, 1, 1) = "0" And Len(Linea) = 1 Then
            CONC_O2.Text = ""
        End If
        If Char.IsControl(e.KeyChar) Then
            e.Handled = False
        End If
        If e.KeyChar = "." And Not Linea.IndexOf(".") Then
            e.Handled = True
        End If
 
    End Sub
 
    Private Sub CONC_N2_KeyPress(sender As Object, e As KeyPressEventArgs) Handles CONC_N2.KeyPress
        Dim Linea As String = CONC_N2.Text
        Dim Numeros As String = "1234567890"
        If Len(Linea) = 0 Then
            Numeros += "-"
        End If
        If Len(Linea) > 0 Then
            Numeros += "."
        End If
        For Each caracter In Numeros
            If e.KeyChar = caracter Then
                e.Handled = False
                Exit For
            Else
                e.Handled = True
            End If
        Next
        If e.KeyChar = "0" And Mid(Linea, 1, 1) = "0" And Len(Linea) = 1 Then
            CONC_N2.Text = ""
        ElseIf e.KeyChar <> "0" And e.KeyChar <> "." And Mid(Linea, 1, 1) = "0" And Len(Linea) = 1 Then
            CONC_N2.Text = ""
        End If
        If Char.IsControl(e.KeyChar) Then
            e.Handled = False
        End If
        If e.KeyChar = "." And Not Linea.IndexOf(".") Then
            e.Handled = True
        End If
 
    End Sub
 
    Private Sub ComboBox1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles ComboBox1.KeyPress
        e.KeyChar = ""
    End Sub
 
    Private Sub ComboBox2_KeyPress(sender As Object, e As KeyPressEventArgs) Handles ComboBox1.KeyPress
        e.KeyChar = ""
    End Sub
 
    Private Sub Button_calcular_Click(sender As Object, e As EventArgs) Handles Button_calcular.Click
 
        If Text_PRES.Text = "" Then
            MsgBox("Introducir Valor a presión.", MsgBoxStyle.Information, "presion")
        Else
            If ComboBox1.SelectedIndex = -1 Then
                MsgBox("Seleccionar presión.", MsgBoxStyle.Information, "presion")
            Else
                If Text_TEM.Text = "" Then
                    MsgBox("Introducir valor a temperatura.", MsgBoxStyle.Information, "Temperatura")
                Else
                    If ComboBox2.SelectedIndex = -1 Then
                        MsgBox("Seleccionar temperatura.", MsgBoxStyle.Information, "Temperatura")
                    Else
                        If CONC_CO2.Text = "" Then
                            MsgBox("Introducir Valor a concentración.", MsgBoxStyle.Information, "Concentracion")
                        Else
                            If CONC_CO2.Text = "" Then
                                MsgBox("Introducir Valor a concentración.", MsgBoxStyle.Information, "Concentracion")
                            Else
                                If CONC_O2.Text = "" Then
                                    MsgBox("Introducir Valor a concentración.", MsgBoxStyle.Information, "Concentracion")
                                Else
                                    If CONC_N2.Text = "" Then
                                        MsgBox("Introducir Valor a concentración.", MsgBoxStyle.Information, "Concentracion")
                                    Else
                                        Dim total As Double
                                        total = Val(CONC_CO2.Text) + Val(CONC_N2.Text) + Val(CONC_O2.Text)
                                        Label12.Text = total
                                        If Label12.Text < 1 Then
                                            MsgBox("Concentracion fuera de rango, es menor a 1.", MsgBoxStyle.Information, "Fuera de Rango")
                                        Else
                                            If Label12.Text > 1 Then
                                                MsgBox("Concentracion fuera de rango, es mayor a 1.", MsgBoxStyle.Information, "Fuera de Rango")
                                            Else
 
                                                Dim conce1, conce2, conce3 As Double
                                                    conce1 = (CONC_CO2.Text) / 1000
                                                    conce2 = CONC_O2.Text / 1000
                                                    conce3 = CONC_N2.Text / 1000
 
                                                    Dim pm_co2, pm_o2, pm_n2 As Double
 
                                                    pm_co2 = 44.01
                                                    pm_n2 = 28.02
                                                    pm_o2 = 32
 
                                                    Dim visCo2, visO2, visN2 As Double
                                                    visCo2 = 1462 * (10 ^ -7)
                                                    visN2 = 1754 * (10 ^ -7)
                                                    visO2 = 2031 * (10 ^ -7)
 
                                                    Dim M1, V1, Qab1 As Double
                                                    Dim M2, V2, Qab2 As Double
                                                    Dim M3, V3, Qab3 As Double
                                                    Dim M4, V4, Qab4 As Double
                                                    Dim M5, V5, Qab5 As Double
                                                    Dim M6, V6, Qab6 As Double
                                                    Dim M7, V7, Qab7 As Double
                                                    Dim M8, V8, Qab8 As Double
                                                    Dim M9, V9, Qab9 As Double
                                                    Dim s1, s2, s3 As Double
                                                    Dim M10 As Double
                                                    Dim M11 As Double
                                                    Dim M12 As Double
                                                    Dim M13 As Double
                                                    Dim M14 As Double
                                                    Dim M15 As Double
                                                    Dim M16 As Double
                                                    Dim M17 As Double
                                                    Dim M18 As Double
 
 
 
                                                    M1 = pm_co2 / pm_co2
                                                    M2 = pm_co2 / pm_o2
                                                    M3 = pm_co2 / pm_n2
                                                    M4 = pm_o2 / pm_co2
                                                    M5 = pm_o2 / pm_o2
                                                    M6 = pm_o2 / pm_n2
                                                    M7 = pm_n2 / pm_co2
                                                    M8 = pm_n2 / pm_o2
                                                    M9 = pm_n2 / pm_n2
                                                    M10 = pm_co2 / pm_co2
                                                    M11 = pm_o2 / pm_co2
                                                    M12 = pm_n2 / pm_co2
                                                    M13 = pm_co2 / pm_o2
                                                    M14 = pm_o2 / pm_o2
                                                    M15 = pm_n2 / pm_o2
                                                    M16 = pm_co2 / pm_n2
                                                    M17 = pm_o2 / pm_n2
                                                    M18 = pm_n2 / pm_n2
 
                                                    V1 = visCo2 / visCo2
                                                    V2 = visCo2 / visO2
                                                    V3 = visCo2 / visN2
                                                    V4 = visO2 / visCo2
                                                    V5 = visO2 / visO2
                                                    V6 = visO2 / visN2
                                                    V7 = visN2 / visCo2
                                                    V8 = visN2 / visO2
                                                    V9 = visN2 / visN2
 
                                                    Qab1 = (1 / Math.Sqrt(8)) * ((1 + M1) ^ (-1 / 2)) * (((1 + (V1 ^ (1 / 2)) * (M10 ^ (1 / 4))) ^ 2))
                                                    Qab2 = (1 / Math.Sqrt(8)) * ((1 + M2) ^ (-1 / 2)) * (((1 + (V2 ^ (1 / 2)) * (M11 ^ (1 / 4))) ^ 2))
                                                    Qab3 = (1 / Math.Sqrt(8)) * ((1 + M3) ^ (-1 / 2)) * (((1 + (V3 ^ (1 / 2)) * (M12 ^ (1 / 4))) ^ 2))
                                                    Qab4 = (1 / Math.Sqrt(8)) * ((1 + M4) ^ (-1 / 2)) * (((1 + (V4 ^ (1 / 2)) * (M13 ^ (1 / 4))) ^ 2))
                                                    Qab5 = (1 / Math.Sqrt(8)) * ((1 + M5) ^ (-1 / 2)) * (((1 + (V5 ^ (1 / 2)) * (M14 ^ (1 / 4))) ^ 2))
                                                    Qab6 = (1 / Math.Sqrt(8)) * ((1 + M6) ^ (-1 / 2)) * (((1 + (V6 ^ (1 / 2)) * (M15 ^ (1 / 4))) ^ 2))
                                                    Qab7 = (1 / Math.Sqrt(8)) * ((1 + M7) ^ (-1 / 2)) * (((1 + (V7 ^ (1 / 2)) * (M16 ^ (1 / 4))) ^ 2))
                                                    Qab8 = (1 / Math.Sqrt(8)) * ((1 + M8) ^ (-1 / 2)) * (((1 + (V8 ^ (1 / 2)) * (M17 ^ (1 / 4))) ^ 2))
                                                    Qab9 = (1 / Math.Sqrt(8)) * ((1 + M9) ^ (-1 / 2)) * (((1 + (V9 ^ (1 / 2)) * (M18 ^ (1 / 4))) ^ 2))
 
                                                    s1 = ((Qab1 * conce1) + (Qab2 * conce2) + (Qab3 * conce3))
                                                    s2 = ((Qab4 * conce1) + (Qab5 * conce2) + (Qab6 * conce3))
                                                    s3 = ((Qab7 * conce1) + (Qab8 * conce2) + (Qab9 * conce3))
 
                                                    DataGridView1.Rows(0).Cells(2).Value = Truncar(M1, 6)
                                                    DataGridView1.Rows(0).Cells(3).Value = Truncar(V1, 3)
                                                    DataGridView1.Rows(0).Cells(4).Value = Truncar(Qab1, 3)
                                                    DataGridView1.Rows(1).Cells(2).Value = Truncar(M2, 3)
                                                    DataGridView1.Rows(1).Cells(3).Value = Truncar(V2, 3)
                                                    DataGridView1.Rows(1).Cells(4).Value = Truncar(Qab2, 3)
                                                    DataGridView1.Rows(1).Cells(5).Value = Truncar(s1, 3)
                                                    DataGridView1.Rows(2).Cells(2).Value = Truncar(M3, 3)
                                                    DataGridView1.Rows(2).Cells(3).Value = Truncar(V3, 3)
                                                    DataGridView1.Rows(2).Cells(4).Value = Truncar(Qab3, 3)
                                                    DataGridView1.Rows(3).Cells(2).Value = Truncar(M4, 3)
                                                    DataGridView1.Rows(3).Cells(3).Value = Truncar(V4, 3)
                                                    DataGridView1.Rows(3).Cells(4).Value = Truncar(Qab4, 3)
                                                    DataGridView1.Rows(4).Cells(2).Value = Truncar(M5, 3)
                                                    DataGridView1.Rows(4).Cells(3).Value = Truncar(V5, 3)
                                                    DataGridView1.Rows(4).Cells(4).Value = Truncar(Qab5, 3)
                                                    DataGridView1.Rows(4).Cells(5).Value = Truncar(s2, 3)
                                                    DataGridView1.Rows(5).Cells(2).Value = Truncar(M6, 3)
                                                    DataGridView1.Rows(5).Cells(3).Value = Truncar(V6, 3)
                                                    DataGridView1.Rows(5).Cells(4).Value = Truncar(Qab6, 3)
                                                    DataGridView1.Rows(6).Cells(2).Value = Truncar(M7, 3)
                                                    DataGridView1.Rows(6).Cells(3).Value = Truncar(V7, 3)
                                                    DataGridView1.Rows(6).Cells(4).Value = Truncar(Qab7, 3)
                                                    DataGridView1.Rows(7).Cells(2).Value = Truncar(M8, 3)
                                                    DataGridView1.Rows(7).Cells(3).Value = Truncar(V8, 3)
                                                    DataGridView1.Rows(7).Cells(4).Value = Truncar(Qab8, 3)
                                                    DataGridView1.Rows(7).Cells(5).Value = Truncar(s3, 3)
                                                    DataGridView1.Rows(8).Cells(2).Value = Truncar(M9, 3)
                                                    DataGridView1.Rows(8).Cells(3).Value = Truncar(V9, 3)
                                                    DataGridView1.Rows(8).Cells(4).Value = Truncar(Qab9, 3)
 
                                                    Dim Resultado As Double
                                                    Resultado = ((conce1 * visCo2) / s1) + ((conce2 * visO2) / s2) + ((conce3 * visN2) / s3)
                                                    RES.Text = Resultado & " g/cm*s"
                                                End If
 
                                            End If
                                        End If
                                    End If
                                End If
                            End If
                        End If
                    End If
                End If
            End If
 
 
    End Sub
    Public Function Truncar(ByVal Numero As Double, Optional ByVal Decimales As Byte = 0) _
        As Double
        Dim lngPotencia As Long
        lngPotencia = 10 ^ Decimales
        Numero = Int(Numero * lngPotencia)
        Truncar = Numero / lngPotencia
    End Function
 
    Private Sub DataGridView2_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView2.CellContentClick
 
 
 
        Dim row0 As String = DataGridView2.Rows(0).Cells(0).Value = "1"
        DataGridView2.Rows(0).Cells(1).Value = "CO2"
        DataGridView2.Rows(0).Cells(2).Value = "0.133"
        DataGridView2.Rows(0).Cells(3).Value = "44.01"
        DataGridView2.Rows(0).Cells(4).Value = "1462*10-7 g/cm*s"
 
        Dim row1 As String = DataGridView2.Rows(1).Cells(0).Value = "2"
        DataGridView2.Rows(1).Cells(1).Value = "O2"
        DataGridView2.Rows(1).Cells(2).Value = "0.039"
        DataGridView2.Rows(1).Cells(3).Value = "32"
        DataGridView2.Rows(1).Cells(4).Value = "2031*10-7 g/cm*s"
 
        Dim row2 As String = DataGridView2.Rows(1).Cells(0).Value = "2"
        DataGridView2.Rows(2).Cells(1).Value = "3"
        DataGridView2.Rows(2).Cells(2).Value = "N2"
        DataGridView2.Rows(2).Cells(2).Value = "0.828"
        DataGridView2.Rows(2).Cells(3).Value = "28.02"
        DataGridView2.Rows(2).Cells(4).Value = "1754*10-7 g/cm*s"
 
    End Sub
 
    Private Sub RES_KeyPress(sender As Object, e As KeyPressEventArgs) Handles RES.KeyPress
        Dim Linea As String = RES.Text
        Dim Numeros As String = " "
        If Len(Linea) = 0 Then
            Numeros += "-"
        End If
        If Len(Linea) > 0 Then
            Numeros += "."
        End If
        For Each caracter In Numeros
            If e.KeyChar = caracter Then
                e.Handled = False
                Exit For
            Else
                e.Handled = True
            End If
        Next
        If e.KeyChar = "0" And Mid(Linea, 1, 1) = "0" And Len(Linea) = 1 Then
            RES.Text = ""
        ElseIf e.KeyChar <> "0" And e.KeyChar <> "." And Mid(Linea, 1, 1) = "0" And Len(Linea) = 1 Then
            RES.Text = ""
        End If
        If Char.IsControl(e.KeyChar) Then
            e.Handled = False
        End If
        If e.KeyChar = "." And Not Linea.IndexOf(".") Then
            e.Handled = True
        End If
    End Sub
 
    Private Sub RES_TextChanged(sender As Object, e As EventArgs) Handles RES.TextChanged
 
    End Sub
 
    Private Sub Label12_Click(sender As Object, e As EventArgs) Handles Label12.Click
 
    End Sub
 
    Private Sub Label7_Click(sender As Object, e As EventArgs) Handles Label7.Click
 
        If Label7.Text < 1 Then
            MsgBox("Presión fuera del rango.", MsgBoxStyle.Information, "Viscosidad")
        ElseIf Label7.Text > 10 Then
 
            MsgBox("Presión fuera del rango.", MsgBoxStyle.Information, "Viscosidad")
            Else
                If Text_PRES.Text = "" Then
                    MessageBox.Show("FALTAN DATOS", "INFORMACIÓN", MessageBoxButtons.OK, MessageBoxIcon.Information)
                End If
 
            End If
 
 
    End Sub
End Class



Comentarios sobre la versión: 3.33 (0)


No hay comentarios
 

Comentar la versión: 3.33

Nombre
Correo (no se visualiza en la web)
Valoración
Comentarios...
CerrarCerrar
CerrarCerrar
Cerrar

Tienes que ser un usuario registrado para poder insertar imágenes, archivos y/o videos.

Puedes registrarte o validarte desde aquí.

Codigo
Negrita
Subrayado
Tachado
Cursiva
Insertar enlace
Imagen externa
Emoticon
Tabular
Centrar
Titulo
Linea
Disminuir
Aumentar
Vista preliminar
sonreir
dientes
lengua
guiño
enfadado
confundido
llorar
avergonzado
sorprendido
triste
sol
estrella
jarra
camara
taza de cafe
email
beso
bombilla
amor
mal
bien
Es necesario revisar y aceptar las políticas de privacidad

http://lwp-l.com/s4674