2017-06-19 46 views
-1

如何優化我的代碼還有其他方法嗎?如何優化我的代碼

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 

回答

0

捕捉然後拋出一個新的Exception似乎毫無意義。刪除。

+0

先生?在哪裏?有沒有其他辦法可以縮短這段代碼? –