|
-
Feb 16th, 2007, 12:51 AM
#1
Thread Starter
Junior Member
Hellp
I keep getting an error messege that says :
Conversion from string "" to type "integer" is not valid?!?!!?
what should i do?? what am i doing wrong?
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calculate.Click
Dim thenumber, theterms, z As Integer
Dim thesum As Decimal
thenumber = CInt(number.Text)
theterms = CInt(terms.Text)
thesum = CDec(sum.Text)
theterms = 1
thesum = 0
Do Until thesum > thenumber
z = 1 / theterms
thesum = z
Exit Do
z = z + z
theterms = theterms + 1
Loop
terms.Text = CStr(theterms)
sum.Text = CStr(thesum)
End Sub
End Class
-
Feb 16th, 2007, 12:56 AM
#2
Re: Hellp
Dim thenumber, theterms, z As Integer
This is an incorrect way of dimming
Try this
VB Code:
Dim thenumber As Integer, theterms As Integer, z As Integer
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Feb 16th, 2007, 12:59 AM
#3
Re: Hellp
Exactly! You get that error because thenumber and theterms are declared as variants.
Do what koolsid suggested.
-
Feb 16th, 2007, 01:02 AM
#4
Thread Starter
Junior Member
Re: Hellp
i changed it around a little bit, but same problem...i get that messege
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calculate.Click
Dim thenumber As Integer
Dim theterms As Integer
Dim z As Integer
Dim n As Integer
Dim thesum As Decimal
thenumber = CInt(number.Text)
theterms = CInt(terms.Text)
thesum = CDec(sum.Text)
theterms = 1
thesum = 0
z = 1 / n
n = 1
Do While thesum < thenumber
thesum = z
z = z + z
n = n + 1
Loop
terms.Text = CStr(theterms)
sum.Text = CStr(thesum)
-
Feb 16th, 2007, 01:04 AM
#5
Thread Starter
Junior Member
Re: Hellp
The sum of the series 1/1 +1/2 +1/3.... never converges. Thus if you add enough terms you can reach any value/ For example it takes 4 terms of the series to reach 2 as 1 + 1/2 +1/3 +1/4 is 2.0833333 and 11 terms to reach 3.
AM i writing this program right???
-
Feb 16th, 2007, 01:15 AM
#6
Re: Hellp
I think this should be move to VB.Net however, why are you using integers? Try using double.
-
Feb 16th, 2007, 02:14 AM
#7
Re: Hellp
theterms = 1
thesum = 0
z = 1 / n
n = 1
Have you declared the value of 'n' elsewhere before 'z = 1 / n'?
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Feb 16th, 2007, 02:25 AM
#8
Re: Hellp
He's doubleposting the same topic! I suggest to reply only on the other one!
The other post
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Feb 16th, 2007, 02:30 AM
#9
Re: Hellp
He's doubleposting the same topic!
lol...
Sorry I must have missed the other post.
@cthompson86: Please do not make duplicate threads. You will end up confusing yourself and others too... besides it is not allowed
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|