From: WatsonR@IntelligenCIA.com   
      
   "Basil Fawlty" wrote in message   
   news:4-udnWAlucA9P6nfRVn-pQ@comcast.com...   
   > Below is where I have the code now, I do a Build with no errors, and then   
   go   
   > to Debug, Start and the program pops up, I key in a radius, then height   
   > number, and click ok, it does nothing. And, maybe due to the mode I am   
   > running the program, the text boxes all have text like radius.Text and   
   such   
   > in them.   
   >   
   > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As   
   > System.EventArgs) Handles Button1.Click   
   >   
   > Dim r As Single, h As Single, pi As Single, v As Single, radius As Single,   
   > hght As Single, volume As Single   
   >   
   > r = Val(radius)   
   >   
   > h = Val(hght)   
   >   
   > pi = 22 / 7   
   >   
   > v = pi * (r ^ 2) * h   
   >   
   > volume = Str$(v)   
   >   
   > End Sub   
   >   
   >   
   > "Basil Fawlty" wrote in message   
   > news:y4udnZWM4f4O96nfRVn-2Q@comcast.com...   
   > > Hi everyone, I have an assignment, to create a simple VB program that   
   > > computes the volume of a cylinder. The Form is pretty simple, it has a   
   > > label and text box for base radius, another for height and another for   
   > > volume with an OK button. I have the code to put into the OK button   
   > > (Which   
   > > I've done):   
   > >   
   > > Private Sub OK_Click( ) --not this line   
   > > r = Val(radius.Text) --input this line   
   > > h = Val(hght.Text) --input this line   
   > > pi = 22 / 7 --input this line   
   > > v = pi * (r ^ 2) * h --input this line   
   > > volume.Text= Str$(v) --input this line   
   > > End Sub --not this line   
   > >   
   > >   
   > > When I go to run the Build, it complains I have not declared the   
   variables   
   > > that you see above. Where do I goto do that? I assume under the label   
   or   
   > > text box for the base radius, and so forth, but which one? What do I   
   key   
   > > into them that is syntactically correct to match the code I was given to   
   > > use?   
   > >   
   > > I am using VB.NET 2003 SE. Please let me know if I need to post more   
   > > code,   
   > > and where I would get it from to post.   
   > >   
   > > My many thanks for any assistance.   
   > >   
   > >   
   >   
   >   
   You're making it too complicated. This is not VB net but should work. Just   
   have two text boxes 9one for radius and one for height) and a label.   
      
   Private Sub Command1_Click()   
   Dim pi   
    pi = 3.141592   
    Label1.Caption = pi * (Val(Text1.Text) ^ 2) * Val(Text2.Text)   
   End Sub   
      
   Also, use 22/7 only when you have to estimate in your head. If you have a   
   computer, use 3.1415.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|