问题描述
要求:输入各项消费。并计算出报销金额。其中吃饭费用报销50%。2个框体已经给出。在输入阶段listbox是隐藏的,当点击按钮后,显示出相应信息PublicClassForm2PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickDimfrmstrAsString="{0,-30}{1,15:C)"DimOrganizationAsString=TextBox1.TextDimondateAsString=TextBox2.TextDimLocationAsString=TextBox3.TextDimmealsAsDouble=CDbl(TextBox4.Text)DimairlineAsDouble=CDbl(TextBox5.Text)DimlodgingAsDouble=CDbl(TextBox6.Text)DimtaxiAsDouble=CDbl(TextBox7.Text)Inputinfo(Organization,ondate,Location,meals,_airline,lodging,taxi)outfile(Organization,ondate,Location,meals,_airline,lodging,taxi)EndSubSubInputinfo(ByValOrganizationAsString,ByValondateAsString,ByValLocationAsString,_ByValmealsAsDouble,ByValairlineAsDouble,ByVallodgingAsDouble,ByValtaxiAsDouble)Organization=TextBox1.Textondate=TextBox2.TextLocation=TextBox3.Textmeals=CDbl(TextBox4.Text)airline=CDbl(TextBox5.Text)lodging=CDbl(TextBox6.Text)taxi=CDbl(TextBox7.Text)EndSubFunctionTravelExpense(ByValaAsDouble,ByValbAsDouble,ByValcAsDouble,ByValdAsDouble)AsDouble'ameanmealsexpense'bmenaairlineexpense'cmeanlodgingexpense'dmeantaxiexpenseReturna*0.5+b+c+dEndFunctionSuboutfile(ByValOrganizationAsString,ByValondateAsString,ByValLocationAsString,_ByValmealsAsDouble,ByValairlineAsDouble,ByVallodgingAsDouble,ByValtaxiAsDouble)DimfrmstrAsString="{0,-30}{1,15:C)"WithForm1.ListBox1.Items.Add("BussinessTravelExpense").Add("Triptoattendmeetingof"_&Organization).Add(ondate&"in"&Location).Add("").Add(String.Format(frmstr,"Mealandentertainment",TextBox4.Text)).Add(String.Format(frmstr,"Airplanefare",TextBox5.Text)).Add(String.Format(frmstr,"Lodging",TextBox6.Text)).Add(String.Format(frmstr,"Taxifares",TextBox7.Text)).Add("").Add("Totalotherthanmealsandentertainment:"_&FormatCurrency(TravelExpense(meals,airline,lodging,taxi))).Add("50%ofmealsandentertainment:"&FormatCurrency(meals*0.5)).Clear()EndWithEndSubEndClass
这个是我做的程序,但是调试总是有误,输出位置字符串无法转换。
解决方案
解决方案二:
该回复于2012-04-17 13:34:36被版主删除
解决方案三:
.Add(String.Format(frmstr,"Mealandentertainment",TextBox4.Text)).Add(String.Format(frmstr,"lanefare",TextBox5.Text)).Add(String.Format(frmstr,"Lodging",TextBox6.Text)).Add(String.Format(frmstr,"Taxifares",TextBox7.Text))
此段出错,未处理的FormatException.输入字符串的格式不正确.求解释