Hi all!
I need help with Visual Basic..

Write a program that reads 3 integers numbers, then the program prints the square and cube of each.
i want a one button and one label in form
and the result i want in label .
and thank you all

Recommended Answers

All 4 Replies

This answer in array I want to answer in random please.

Dim NumOfIntegers() As Integer = {1, 2, 3, 4, 8}
        Dim x, y As Integer
        For Each num As Integer In NumOfIntegers
            x = num ^ 2
            y = num ^ 3
            MessageBox.Show("Square Of " & num & " = " & x & vbCrLf & "Cube Of " & num & " = " & y)

What do you mean by random?
Or do you have trouble with the button event click handler?

Your codes are quiet correct. To display as you desire you have to add string values through a loop to the label text property and do label's AutoSize property to False at design time or by code.

For Each num As Integer In NumOfIntegers
                   Label1.Text &= String.Format("Square Of {0} = {1}{2}Cube Of {0} = {3}{2}",num,num^2,vbcrlf,num^3)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.