Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

having problem in showing output in VB?

Last post 05-06-2008 9:31 AM by ripanbiswas. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 05-05-2008 6:02 AM

    • 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
  • 05-06-2008 6:13 AM In reply to

    Re: having problem in showing output in VB?

     

     

    Filed under:
    • Post Points: 5
  • 05-06-2008 6:14 AM In reply to

    Re: having problem in showing output in VB?

    check the latest

    • Post Points: 5
  • 05-06-2008 9:31 AM In reply to

    Re: having problem in showing output in VB?

    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)
                    If f < 3 Then
                    Str1 = Str1 & (" " & matrix3(i2, f2))
                    Else
                    Str1 = Str1 & (" " & matrix3(i2, f2)) & vbCrLf
                    End If
                  
                   
                  

                Next f
               
             Next i
           

       Next e
    Next j

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


               
    End Sub

    • Post Points: 5
Page 1 of 1 (4 items)