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

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.