i have decleared all variables as double.
Sub kaat()

    goldkaatinratti = (Val(txtbox_tolagoldweight.Text * 96) + Val(txtbox_mashagoldweight.Text * 8) + Val(txtbox_rattigoldweight.Text)) * 8 / 96

End Sub

but when i leave the textboxes empty it gives ma the error (Conversion from string "" to type 'Double' is not valid.)
i CANNOT give this statement as this all ruins my future calculation.

        'If txtbox_tolagoldweight.Text = "" Then
        '    txtbox_tolagoldweight.Text = 0
        'End If
        'If txtbox_mashagoldweight.Text = "" Then
        '    txtbox_mashagoldweight.Text = 0
        'End If
        'If txtbox_rattigoldweight.Text = "" Then
        '    txtbox_rattigoldweight.Text = 0
        'End If

here is the screenshot

Edited 3 Years Ago by Reverend Jim: fixed formatting

You can't convert a null string to a number. You'll have to decide how you want to treat non-numeric entries. What do you want to do if no value is entered? What about non-blank but non-numeric values such as "abc" or "1.2.3"? We can't make those decisions for you.

By the way, the link to your image was not formatted correctly. I fixed it.

Edited 3 Years Ago by Reverend Jim

You will get this error because using of Val() function.
e.g : Val(txtbox_tolagoldweight.Text * 96), you just multiply string with number.

try this :

Sub kaat()
    goldkaatinratti = (((Val(TextBox1.Text) * 96) + (Val(TextBox2.Text) * 8)) + (Val(TextBox3.Text) * 8)) / 96
End Sub

Edited 3 Years Ago by Jx_Man

@Reverend Jim:
if i give them zero then i cant go with another type of input from a textbox in grams. so thats why i cant empty textboxes to do nothing when they are empty.

@jx Man : thanks that worked with little changes in brackets at the end.

Sub kaat()
                goldkaatinratti = (((Val(txtbox_tolagoldweight.Text) * 96) + (Val(txtbox_mashagoldweight.Text) *  8)) + (Val(txtbox_rattigoldweight.Text))) * 8 / 96
    End Sub
This question has already been answered. Start a new discussion instead.