I am doing a project in microsoft visual studio 2012 and i am trying to write an application to determine the module average.

The script is the following:

```js
 Private Sub Button2_Click(sender As Object, e As EventArgs) Handles confirm.Click
        Dim sum As Double
        sum = CDbl(test.Text) * 50% + CDbl(project.Text) * 30% + CDbl(quiz.Text) * 30%
        Dim modulemark As Double
        modulemark = CDbl(CAmarks.Text) * 50% + CDbl(exam.Text) * 50%

        Dim Grade As String
        If sum < 40 Then
            Grade = "F"
        ElseIf sum >= 40 And modulemark < 65 And modulemark >= 40 Then
            Grade = "C"
        ElseIf sum >= 40 And modulemark < 75 And modulemark >= 65 Then
            Grade = "B"
        Else
            Grade = "A"
        End If
```

The script is intended to calculate the marks and give a grade after clicking a button named "Confirm".

However, when i tried to run the coding it said:

An unhandled exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll

Additional information: Conversion from string "" to type 'Double' is not valid.

can someone see what is wrong? i am new to Visual studio and i appreciate your help.

P.S. edited recent script.

P.S. Thank you for the user "Tim" for the script ~~but for some unknown reason on the line "Double.TryParse(caMarks.Text, caMarks)" there's a blue squiggly that directs to caMarks that says "'Text' is not a member of 'double'". This is literally pulling my hair off! please help!~~

It looks like the names of the objects conflicted.