如何优化我的代码

时间:2017-06-19 03:43:23

标签: visual-studio-2010

还有其他方法可以改进我的代码吗?

Sub save_item(ByVal strtype As String, ByVal strgendes As String, ByVal strquantity As String, ByVal strfund As String, ByVal strebudget As String, _
                  ByVal strtotaltenpercent As String, ByVal strjan As String, ByVal strfeb As String, ByVal strmarch As String, _
                  ByVal strapril As String, ByVal strmay As String, ByVal strjune As String, ByVal strjuly As String, _
                  ByVal straug As String, ByVal strsept As String, ByVal stroct As String, ByVal strnov As String, ByVal strdec As String, _
                  ByVal strq1 As String, ByVal strq2 As String, ByVal strq3 As String, ByVal strq4 As String, ByVal strtotal_item As String,
_
                  ByVal strtotalprice As String, ByVal strdate As String, ByVal stryear As String)

    Dim saveall As New tblPPMP With {.Type = strtype, _
                                     .GenDes = strgendes, _
                                     .Quantity = strquantity, _
                                     .Fund = strfund, _
                                     .Ebudget = strebudget, _
                                     .Total_tenpercent = strtotaltenpercent, _
                                     .Jan = strjan, _
                                     .Feb = strfeb, _
                                     .March = strmarch, _
                                     .April = strapril, _
                                     .May = strmay, _
                                     .June = strjune, _
                                     .Jul = strjuly, _
                                     .Aug = straug, _
                                     .Sept = strsept, _
                                     .Oct = stroct, _
                                     .Nov = strnov, _
                                     .Dec = strdec, _
                                     .Q1 = strq1, _
                                     .Q2 = strq2, _
                                     .Q3 = strq3, _
                                     .Q4 = strq4, _
                                     .Total_Item = strtotal_item, _
                                     .Total_Price = strtotalprice, _
                                     .dr_date = strdate, _
                                     .dr_year = stryear}

    dbcon.tblPPMPs.InsertOnSubmit(saveall)
    MsgBox("Save Successfully")
    Try
        dbcon.SubmitChanges()
    Catch ex As Exception

    End Try
End Sub

1 个答案:

答案 0 :(得分:0)

捕获然后抛出一个新的异常似乎毫无意义。删除它。