列不会分开或对齐 [英] Columns Won't Separate or Align

查看:47
本文介绍了列不会分开或对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我真的需要帮助.我现在一直困扰于两个项目的列和对齐方式相同的问题,我感到非常困惑.

Hi, I really need help here. I've been stuck on the same problem of columns and alignments for 2 projects now and I am very confused.

如果有人可以告诉我我要去哪里,那太好了.

If someone could show me where I am going wrong, that would be great. 

这是我的代码.

公共类Form1

   私有Sub btnCompute_Click(作为对象发送,作为EventArgs发送)处理btnCompute.Click

      牛肉作为整数
      素食主义者Integer
      总暗淡为整数
      暗淡牛肉价格翻倍
      昏暗的vegancost作为Double
      小费作为Double
      双人房的暗淡房费
      双人间含暗室税
       Dim grandtotal As Double
      昏暗的fmtStr作为字符串

      牛肉= CInt(txtBeef.Text)
      素食主义者= CInt(txtVegan.Text)
      总计= CInt(牛肉+素食主义者)
      牛肉成本= CDbl(牛肉* 15.95)
       vegancost = CDbl(素食* 10.95)
      小费= CDbl((beefcost + vegancost)* 0.18)

      如果总计< = 50那么
          房间税= CDbl(75 * 0.065)
       ElseIf total< = 100那么
          房间税= CDbl(150 * 0.065)
      其他
          房间税= CDbl(250 * 0.065)
      如果结束

      如果总数< = 50那么
          房间费用= CDbl(75)
       ElseIf total< = 100那么
          房间费用= CDbl(150)
      其他
          房间费用= CDbl(250)
      如果结束

      总计= CDbl(早餐+素食+小费+房费+房税)
       fmtStr ="{0,-20} {1,15} {2,-20} {3,15:C}"

      使用lstOut.Items
           .Add(String.Format(fmtStr,聚会中的人数",总计,","))
           .Add(String.Format(fmtStr,"Room Cost",",",roomcost))
           .Add(String.Format(fmtStr,"Room Tax",",,",roomtax))
           .Add(String.Format(fmtStr,牛肉餐",牛肉,牛肉成本",牛肉成本))
           .Add(String.Format(fmtStr,"Vegan Meals",素食主义者,"Vegan Cost",vegancost))
           .Add(String.Format(fmtStr,"Gratuity",",,",小费))
           .Add(String.Format(fmtStr,总计",,",,总计"))
      结尾为

   结束子
结束班

Public Class Form1

    Private Sub btnCompute_Click(sender As Object, e As EventArgs) Handles btnCompute.Click

        Dim beef As Integer
        Dim vegan As Integer
        Dim total As Integer
        Dim beefcost As Double
        Dim vegancost As Double
        Dim gratuity As Double
        Dim roomcost As Double
        Dim roomtax As Double
        Dim grandtotal As Double
        Dim fmtStr As String

        beef = CInt(txtBeef.Text)
        vegan = CInt(txtVegan.Text)
        total = CInt(beef + vegan)
        beefcost = CDbl(beef * 15.95)
        vegancost = CDbl(vegan * 10.95)
        gratuity = CDbl((beefcost + vegancost) * 0.18)

        If total <= 50 Then
            roomtax = CDbl(75 * 0.065)
        ElseIf total <= 100 Then
            roomtax = CDbl(150 * 0.065)
        Else
            roomtax = CDbl(250 * 0.065)
        End If

        If total <= 50 Then
            roomcost = CDbl(75)
        ElseIf total <= 100 Then
            roomcost = CDbl(150)
        Else
            roomcost = CDbl(250)
        End If

        grandtotal = CDbl(beefcost + vegancost + gratuity + roomcost + roomtax)
        fmtStr = "{0,-20}{1,15}{2,-20}{3,15:C}"

        With lstOut.Items
            .Add(String.Format(fmtStr, "Number in Party", total, "", ""))
            .Add(String.Format(fmtStr, "Room Cost", "", "", roomcost))
            .Add(String.Format(fmtStr, "Room Tax", "", "", roomtax))
            .Add(String.Format(fmtStr, "Beef Meals", beef, "Beef Cost", beefcost))
            .Add(String.Format(fmtStr, "Vegan Meals", vegan, "Vegan Cost", vegancost))
            .Add(String.Format(fmtStr, "Gratuity", "", "", gratuity))
            .Add(String.Format(fmtStr, "Grand Total", "", "", grandtotal))
        End With

    End Sub
End Class

推荐答案


这篇关于列不会分开或对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆