User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 397,772 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,541 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser:
Views: 1326 | Replies: 2
Reply
Join Date: Jul 2005
Posts: 19
Reputation: mickyboy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
mickyboy mickyboy is offline Offline
Newbie Poster

errors in my file but not sure whats wrong file attatched

  #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)
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2005
Posts: 18
Reputation: Lalo1985 is an unknown quantity at this point 
Rep Power: 4
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

  #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:
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:
Private Sub optaddition_Click()
    On Error Resume Next
    Dim dblNumber1 As Double
    Dim dblNumber2 As Double
    Dim dblResult As Double
    
    dblNumber1 = CDbl(txtnumber1.Text)
    dblNumber2 = CDbl(txtnumber2.Text)
    dblResult = dblNumber1 + dblNumber2
    
    txtresult.Text = dblResult
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  
Join Date: Jul 2005
Posts: 19
Reputation: mickyboy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
mickyboy mickyboy is offline Offline
Newbie Poster

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

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Visual Basic 4 / 5 / 6 Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum

All times are GMT -4. The time now is 4:32 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC