errors in my file but not sure whats wrong file attatched

Reply

Join Date: Jul 2005
Posts: 19
Reputation: mickyboy is an unknown quantity at this point 
Solved Threads: 0
mickyboy mickyboy is offline Offline
Newbie Poster

errors in my file but not sure whats wrong file attatched

 
0
  #1
Jul 9th, 2005
hi all have spent a lot of time recently trying to get the attatched programe to run.

decided to start from scratch,went through the tutorial for vb6 on main page of functionx , tried a few examples and all are ok,except where i had put in code incorrectly.

but this example has got me beat, i get error 13 if i try to run programe.
using debug it points me to a a line of code ,that as far as i can see is exactly the same as code in tutorial.

i put the code in by pasting original code from tutorial to clipboard, and into vb project, but cannot quite find see whats incorrect with my project??

thank you
Attached Files
File Type: zip myvb.zip (2.3 KB, 4 views)
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 18
Reputation: Lalo1985 is an unknown quantity at this point 
Solved Threads: 0
Lalo1985's Avatar
Lalo1985 Lalo1985 is offline Offline
Newbie Poster

Re: errors in my file but not sure whats wrong file attatched

 
0
  #2
Jul 9th, 2005
The problem is that you have your textboxes initialized to strings, which cannot be converted into doubles, so VB complains. The quickest way to make VB ignore this is to add the line:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. On Error Resume Next
at the top of the sub. This tells VB to continue on to the next line when an error arises. It certainly is not the best way to handle errors, but until you decide exactly what you want to do, it will work. So, applying it to your program, it would look like this:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub optaddition_Click()
  2. On Error Resume Next
  3. Dim dblNumber1 As Double
  4. Dim dblNumber2 As Double
  5. Dim dblResult As Double
  6.  
  7. dblNumber1 = CDbl(txtnumber1.Text)
  8. dblNumber2 = CDbl(txtnumber2.Text)
  9. dblResult = dblNumber1 + dblNumber2
  10.  
  11. txtresult.Text = dblResult
  12. End Sub

If you need more help on Error Handling, let me know, and I'll try to explain to you how it works. It's not hard.
Hope this helps.
.:Computer Science is a race between mankind trying to build bigger, faster computer programs, and the universe trying to build bigger, faster idiots... So far the universe is winning:.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 19
Reputation: mickyboy is an unknown quantity at this point 
Solved Threads: 0
mickyboy mickyboy is offline Offline
Newbie Poster

Re: errors in my file but not sure whats wrong file attatched

 
0
  #3
Jul 10th, 2005
thanks lalo in the tutorial it just gives info on the names of the controls such as name frm operations/caption is operations
name optaddition/caption addition

there are three boxes on the left hand side of form shown in the tutorial labeled or marked as below
first number, second number,result with names txtnumber1 txtnumber2 txtresult,

i assumed i needed to add three textboxes , or should i have used a differant control rather than a textbox ????

the code is provided in the tutorial , so know there is an error in the way i have created my form, i can see what you mean (text is text and not a number) what i am unsure of is what i change in my layout/controls of my form for the code to work as it was written.

thank you for your help i need to do a bit more reading practise on vb
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC