Given a 2 dim array write a VB PROGRAM that will add all odd numbers greater than 3. This is my solution but am not that sure so assist me.

if( number % 2 == 1)
____number is odd
else
____number is even

so checking if it's odd and greater than 3 goes like this:
if(number%2==1 && number>3)

Dear betty_vaness,

Continuing is the solution to your requirement.

Deseandote very successful.

bojofien

Sub NumerosImpares ()
'
'NumerosImpares Macro
'

'
Dim f, c, i, j As Integer
Dim MatrizI () As Integer

'Dimensión de Matriz. Determina la Cantidad de filas de columnas y
fil_cantidad = 3
col_cantidad = 2

ReDim MatrizI (0 a fil_cantidad, de 0 a col_cantidad)

'Numeros impares mayores a 3
i = 4
Para f = 0 To (fil_cantidad - 1)
Para c = 0 To (col_cantidad - 1)
j = 1
Do While (j <> 0 And i> 3)
j = (i mod 2)
i = i + 1
Loop
MatrizI (f, c) = i
MsgBox MatrizI (f, c),
Siguiente
Siguiente

End Sub

Edited 6 Years Ago by bojofien: n/a

Dear betty_vaness,

Continuing is the solution to your requirement.

Deseandote very successful.

bojofien

Sub MatrizImpares()
'
'NumerosImpares Macro
'

'
Dim f, c, i, j As Integer
Dim MatrizI() As Integer

    'Dimensión de Matriz. Determina la Cantidad de filas de columnas y
    fil_cantidad = 0
    col_cantidad = 0
    
    If fil_cantidad > 0 And col_cantidad > 0 Then
        ' Redimensionar dimensiones de la Matriz
        ReDim MatrizI(0 To fil_cantidad, 0 To col_cantidad)
        
        'Numeros impares mayores a 3
        i = 4
        For f = 0 To (fil_cantidad - 1)
            For c = 0 To (col_cantidad - 1)
                j = 1
                Do While (j <> 0 And i > 3)
                    j = (i Mod 2)
                    i = i + 1
                Loop
                MatrizI(f, c) = i
                MsgBox MatrizI(f, c)
            Next
        Next
    Else
        MsgBox "Error! Dimensiones no definidas"
    End If
'  End of Sub
End Sub
This article has been dead for over six months. Start a new discussion instead.