Hello!
I was assigned to come up with certain numbers in 2 spaces (X and DX) in order to satisfy 2 different assignments and to be honest it has me quite stumped.
I need to:
The table looks like this
I would greatly appreciate any help you guys might be able to provide. Either the answers or simple guidlines to follow in order to achieve the desired numbers.
Thanks in advance!
I was assigned to come up with certain numbers in 2 spaces (X and DX) in order to satisfy 2 different assignments and to be honest it has me quite stumped.
I need to:
- find 2 numbers which would generate entirely negative table
- find 2 numbers which would generate a table with every pair element (collumns like D4, D6, D8...) to have a negative number in them and every odd column to have numbers of any value (either positive or negative)
Code:
Public Sub genSin()Dim i As Integer, k As Integer
Dim x As Single, dx As Single
Dim y(1 To 20) As Single, maxV As Single
Dim Idet As Integer
Cells(1, 2) = " X"
Cells(1, 3) = " DX"
x = Cells(2, 2)
dx = Cells(2, 3)
For i = 1 To 20 Step 1
y(i) = 10 * Sin(x)
x = x + dx
Next i
For k = 0 To 20 \ 4 - 1
For i = 1 To 4 Step 1
Cells(k + 5, i) = y(k * 4 + i)
Next i
Next k
STEP1:
i = 2
Do While (i <= 21)
If (y(i) > 0) Then
maxV = y(i)
Idet = i
GoTo Step2
Else:
i = i + 2
End If
Loop
MsgBox (" There are no positive numbers in the array.")
GoTo ENDING
Step2:
i = 2
Do While (i <= 21)
If (y(i) > 0) And (y(i) < maxV) Then
maxV = y(i)
Idet = i
i = i + 2
Else
i = i + 2
End If
Loop
MsgBox ("Outcome Idet= " & Idet & " maxv= " & maxV)
Cells(1, 5) = " Idet"
Cells(1, 6) = " maxV"
Cells(2, 5) = Idet
Cells(2, 6) = maxV
ENDING:
End Sub
The table looks like this

I would greatly appreciate any help you guys might be able to provide. Either the answers or simple guidlines to follow in order to achieve the desired numbers.
Thanks in advance!