can i anyone know how to solve a summation problem? in visual basic?

using do while? or do until?

here's my code

x = val(text1.text)

n = val(Text2.text)

c = text3.text

for example if the input of

x is 3 &

n is 2

therefor solving of that is like this

= 3^1 + 3^2

= 3 + 9

= 12

how can i came up this answer? and what if the value in text2.text or n is 3 so

= 3^1 + 3^2 + 3^3

= 3 + 9 27

= 39

and n shoulde be n>=1

and x>0