Message 1 of 4
Trigger Error MessageBox if calling a parameter which doesn't exist
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have some code which is used for various parts. The code uses a few part parameters, but since some parts have certain parameters and others don't, I'm defining the parameters under Select Cases. It gets tedious to make sure all the parameters and errors are called for and only those.
Could I have it that if ever within the code a certain parameter is called for, but it doesn't exist, then trigger the error message (there is Sub Main and multiple functions)?
Thanks!
Here is a piece of the code if it helps to describe the situation...
Select Case Product(Part) Case "02" 'Pipe and DOM ParamParT = FindParameter(invdoc, "ParT") ParamDiam = FindParameter(invdoc, "Diam") If ParamParT Is Nothing Then MessageBox.Show(error1() + vbCrLf + error2, error3 & "ParT") Else pipe_wall = Parameter("ParT") End If If ParamDiam Is Nothing Then MessageBox.Show(error1() + vbCrLf + error2, error3 & "Diam") Else Diam = Parameter("Diam") End If Case "03", "05" 'Angles and Tubes ParamGT = FindParameter(invdoc, "G_T") ParamGH = FindParameter(invdoc, "G_H") ParamGW = FindParameter(invdoc, "G_W") If ParamGT Is Nothing Then MessageBox.Show(error1() + vbCrLf + error2, error3 & "G_T") Else GT = Parameter("G_T") End If If ParamGH Is Nothing Then MessageBox.Show(error1() + vbCrLf + error2, error3 & "G_H") Else GH = Parameter("G_H") End If If ParamGW Is Nothing Then MessageBox.Show(error1() + vbCrLf + error2, error3 & "G_W") Else GW = Parameter("G_W") End If Case "04" 'Flat bars ParamGT = FindParameter(invdoc, "G_T") ParamGW = FindParameter(invdoc, "G_W") If ParamGT Is Nothing Then MessageBox.Show(error1() + vbCrLf + error2, error3 & "G_T") Else GT = Parameter("G_T") End If If ParamGW Is Nothing Then MessageBox.Show(error1() + vbCrLf + error2, error3 & "G_W") Else GW = Parameter("G_W") End If