Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

having problem in showing output in VB?

Last post 05-13-2008 4:55 PM by williamsg. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 05-04-2008 8:39 PM

    • funkyelsie
    • Not Ranked
    • Joined on 05-04-2008
    • Malaysia
    • New Member
    • Points 20

    having problem in showing output in VB?

    hi. i am having problems in showing the output of my matrix multiplication. my output is suppose to be like this:
     

    -1  -1  1  -1

    1   1  -1   1

    -1  -1   1  -1

    1   1    -1  1

    -1  -1    1   -1
     

    but somehow the output that was shown in my graphic user interface is only -1. i do not know what is the problem .

     

     


    Private Sub Calculate_Click()

    Dim Str1 As String
    Dim Str2 As String
    Dim Str3 As String


    Const X As Integer = 5

    Const Y As Integer = 1

    Dim matrix1(X - 1, Y - 1) As Integer
    matrix1(0, 0) = 0
    matrix1(1, 0) = 1
    matrix1(2, 0) = 0
    matrix1(3, 0) = 1
    matrix1(4, 0) = 0


    Const M As Integer = 1
    Const N As Integer = 4

    Dim matrix2(M - 1, N - 1) As Integer
    matrix2(0, 0) = 1
    matrix2(0, 1) = 1
    matrix2(0, 2) = 0
    matrix2(0, 3) = 1

    For j = 0 To (Y - 1)
        For i = 0 To (X - 1)
            If matrix1(i, j) = 0 Then
                matrix1(i, j) = -1
            End If
        Next i
    Next j

    For f = 0 To (N - 1)
        For e = 0 To (M - 1)
            If matrix2(e, f) = 0 Then
                matrix2(e, f) = -1
            End If
        Next e
    Next f

    Dim matrix3(X - 1, N - 1) As Integer
    Dim i2 As Integer
    Dim f2 As Integer


    For j = 0 To (Y - 1)
        For e = 0 To (M - 1)
            For i = 0 To (X - 1)
                For f = 0 To (N - 1)
                  
                    matrix3(i2, f2) = matrix1(i, j) * matrix2(e, f)
                  
                   
                  

                Next f
               
             Next i
           

       Next e
    Next j

     Str1 = (" " & matrix3(i2, f2))
     lbloutput1.Caption = (Str1)


               
    End Sub

     

    • Post Points: 10
  • Advertisement

    • Red Gate Software

    Advertisement

    Want to boost your .NET application performance?

    Some developers always seem to write efficient and lightening-fast code. What is their secret? It’s ANTS Profiler. “We improved the performance of the application up to 10 times” Dan Ports, Intrigma.

    Try it for yourself now.

  • 05-13-2008 4:55 PM In reply to

    • williamsg
    • Not Ranked
    • Joined on 10-11-2007
    • United Kingdom
    • Member
    • Points 235

    Re: having problem in showing output in VB?

     Probably beacuse variables i2 and f2 are never assigned a value and therefore will always be zero.

     This means that you will only ever store or produce the value of your matrix array at Matrix3(0,0)


     

    I code, it's what I do
    • Post Points: 5
Page 1 of 1 (2 items)