Maybe not the right place to aske this, but a newbee (me) needs help.
i trying to input a number into a textbox, so i can make a series of calculations. in the old days of basic i just jused nrstring=val(input) , but life isnt as easy anymore. I brewed something together as a test, but it failes on me.
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles output.TextChanged
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Text1.Click
End Sub
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim volume As Integer
Dim radius As Integer
radius = CDbl("TextBox1")
volume = (4 / 3) * 3.14 * (radius * radius * radius)
MsgBox(radius)
End Sub
End Class
this is the code.
Any help, will get you praised into heaven :-D.
Tnxx in advance.
8 1331
ok, that looked kind of messy.
The lines that should be the problem are:
- Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim volume As Integer
- Dim radius As Integer
- radius = Val(TextBox1.Text)
- volume = (4 / 3) * 3.14 * (radius * radius * radius)
- MsgBox(radius)
- End Sub
his is a changed version. I used Val here, doesnt seem to do the trick either. Sorry about the invenience.
...I brewed something together as a test, but it failes on me.
Can you give us some idea of what goes wrong?
I can point out one error, though... -
radius = CDbl("TextBox1")
-
Pretty sure you need to remove the quotes.
At the moment you are simply trying to convert the string "TextBox1" to a number, which I believe will always produce zero. You should be using the control name TextBox1, which will return the default property of that control.
Also, here's a tip. When posting here, please put CODE and /CODE tags around your code (see example above).
- volume = (4 / 3) * 3.14 * (radius * radius * radius)
- MsgBox(radius)
This is a changed version. I used Val here, doesnt seem to do the trick either. Sorry about the invenience.
I think that's because you displayed radius instead of volume.
(Probably not a good idea to use integers, either - you will lose a lot of precision.)
I think that's because you displayed radius instead of volume.
(Probably not a good idea to use integers, either - you will lose a lot of precision.)
The Volume calculation is just there as part of a larger whole.It can be ignored. The trouble is, the prog throws up at the Val(TextBox1.Text). And i have no idea why.
One praise for you though.
The Volume calculation is just there as part of a larger whole.It can be ignored. The trouble is, the prog throws up at the Val(TextBox1.Text). And i have no idea why.
Can you give us the specific details of how it "throws up"? Remember, in programming the details are everything.
-
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
-
Dim volume As Decimal
-
Dim radius As Decimal
-
radius = CDbl(TextBox1.Text)
-
volume = (4 / 3) * 3.14 * (radius * radius * radius)
-
Label1.Text = volume
-
End Sub
-
-
Works fine with both Val(textbox1.text) and CDbl(Textbox1.text).
changed integer to decimal. And instead of msgbox(radius) i use
label1.text = volume.
Works fine with both Val(textbox1.text) and CDbl(Textbox1.text).
changed integer to decimal. And instead of msgbox(radius) i use
label1.text = volume.
Indeed, it works fine now. I started from scratch, and pasted your code in it. I guess something was wrong with the surounding code, or my pc thought it was a monday. thank you thank you thank you a thousand times. You my friend, have a free ticket to heaven.
Indeed, it works fine now. I started from scratch, and pasted your code in it. I guess something was wrong with the surounding code, or my pc thought it was a monday. thank you thank you thank you a thousand times. You my friend, have a free ticket to heaven.
That's nice to know. :)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Wilfried |
last post by:
I have a form with four numeric fields.
In a textbox on the form I want to calculate the sum of the three highest
numbers of the four fields.
This calculated textbox must then be ordered from high...
|
by: Miguel Morales |
last post by:
Hello:
Currently, I am trying to solve a problem that requires the
calculation of Airy functions for big arguments. Because Airy
functions diverge rapidly for positive values, the results of the...
|
by: Renee |
last post by:
Hi there,
does any one know how to create context sensitive help for Groupbox control
with HelpProvider class?
I can create context sensitive help for any control easily except for
Groupbox.
...
|
by: Kum |
last post by:
Hi,
I need help in asp.net dynamic textbox controls
validation.
I am creating textbox controls dynamically on a
asp.net webpage. Now after creating the textboxes on
the page I want to validate...
|
by: Limpor |
last post by:
Hello, I am new to learning java, and i am trying to build the class for a calculation card game, unfortunately i can't get the public Card top() and Card takeTop() method in the Stock class. Can...
|
by: vinay2110 |
last post by:
i m new to .net programing and dont know how to apply mathematic calculation on the text box. i has the idea to do this thing using auto post back but i dont know what is the exact syntax which will...
|
by: mirasol |
last post by:
i am new here,i just want to ask question about uploading file with textbox using mysql and php, i used the codes given by some member and my problem is i dont know how to add textbox and i want it...
|
by: neelsfer |
last post by:
I have an option group with 2 checkboxes :
MtbAge - option value = 1
RoadAge - option value = 2
The textbox where to display MtbAge/RoadAge is called = currentage
if you select MtbAge it...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |