to print the following in message box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anurathna1971
    New Member
    • Mar 2008
    • 3

    to print the following in message box

    1
    4 9
    16 25 36
  • QVeen72
    Recognized Expert Top Contributor
    • Oct 2006
    • 1445

    #2
    Originally posted by anurathna1971
    1
    4 9
    16 25 36
    Hi,

    I guess, logic here is : Difference between a Number and Prev Number is an odd number (starting from 3). and odd number of elements in each row. Try This:

    [code=vb]
    Dim i As Integer
    Dim S As String
    Dim di As Integer
    Dim TNo As Long
    Dim j As Integer
    S =""
    di= -1
    TNo= 0
    For i = 1 To 3
    For j = 1 To i
    di = di + 2
    TNo = TNo + di
    S = S & " " & TNo
    Next j
    S = S & vbCrLF
    Next i
    MsgBox S
    [/code]

    Regards
    Veena

    Comment

    Working...