| | |
Help please!
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Jul 2008
Posts: 161
Reputation:
Solved Threads: 1
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
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
Hi,
Try this :
Regards
Veena
Try this :
vb Syntax (Toggle Plain Text)
Dim x As Integer Dim n As Integer Dim i As Integer Dim Tot As Double x = val(text1.text) n = val(Text2.text) If n <=0 Or x <1 Then MsgBox "Enter Proper Values" Exit Sub End If Tot = 0 For i = 1 To n Tot = Tot + (x ^ i) Next MsgBox Tot
Regards
Veena
Last edited by QVeen72; Dec 15th, 2008 at 8:35 am.
•
•
Join Date: Jul 2008
Posts: 161
Reputation:
Solved Threads: 1
thnx problem solve, last question how can i solve this?
N N+1
Xi - Xj
I = 1 j = I - 1
for example i input
in my text1.text value of 3
and text2.text value of 2
3 raised to 1 + 3 raised to 2 minu(-) 3 raised to zero + 3 raised to 1 + 3 raised to 2 + 3 raised to 3
the answer should -28
N N+1
Xi - Xj
I = 1 j = I - 1
for example i input
in my text1.text value of 3
and text2.text value of 2
3 raised to 1 + 3 raised to 2 minu(-) 3 raised to zero + 3 raised to 1 + 3 raised to 2 + 3 raised to 3
the answer should -28
Last edited by ryan311; Dec 15th, 2008 at 9:33 am. Reason: forgot
Hi,
Once you know the Logic, you can try playing around with the code.. But any way, here is the code:
OR in One statement
Regards
Veena
Once you know the Logic, you can try playing around with the code.. But any way, here is the code:
vb Syntax (Toggle Plain Text)
Dim x As Integer Dim n As Integer Dim i As Integer Dim Tot As Double x = Val(text1.text) n = Val(Text2.text) If n <=0 Or x <1 Then MsgBox "Enter Proper Values" Exit Sub End If Tot = 0 For i = 1 To n Tot = Tot + (x ^ i) Next For i = 0 To (n +1) Tot = Tot - (x ^ i) Next MsgBox Tot
OR in One statement
vb Syntax (Toggle Plain Text)
Tot = - (x ^ (n+1)) + 1 MsgBox Tot
Regards
Veena
Last edited by QVeen72; Dec 16th, 2008 at 1:36 am.
![]() |
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Please Help!
- Next Thread: help
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





