0

我有以下问题。在我的表格上,我将值“76,50”的表格写为“07650”。现在我想用值 76,50 而不是 07650 在列表框中再次打开我的文件。

Public Class AddwhenOpen 

Public number As Integer
Public name As String
Public Birthday As Integer
Public perc As Decimal
Public comboboxvalue As String

Public Function ToStringForPrinter() As Decimal

Return comboboxvalue & nummer.ToString.PadLeft(5) & naam.PadLeft(5) & Geboortejaar.ToString.PadRight(5) & (perc / 100).ToInt64("00,00")

End Function

类代码

`Public Class ChangeFormatBackToDecimal

Public number As Integer
Public name As String
Public Bday As Integer
Public perc As Decimal
Public comboboxvalue As String

Public Function TostringForPrinter() As String
    Return comboboxvalue & number.ToString.PadLeft(5) & name.PadLeft(5) & Bday.ToString.PadRight(5) & Format(perc / 100, "#00,00")
End Function`

打开文件时的代码...

    Dim index As Integer = 0
    Dim lijn As String

    'Keuzelijst leegmaken.
    lstOutput.Items.Clear()


    With dlgOpenen
        .Filter = "textfiles (*.txt) | *.txt"
        .FileName = ""
        .InitialDirectory = "C:\My Documents"
        .Title = "Open"
    End With

    If dlgOpenen.ShowDialog = DialogResult.OK Then
        FileOpen(1, dlgOpen.FileName, OpenMode.Input)
        Do While Not EOF(1)
            line = LineInput(1)
            lstOutput.Items.Add(line)
        Loop
        FileClose(1)
    End If
    Resetdefaultvalue()

将数据暗淡为新的 ChangeFormatBackToDecimal

    data.comboboxvalue = cboAfdeling.SelectedItem.ToString.PadRight(5) & cboKlasGetal.SelectedItem.ToString & cboAfdeling.SelectedItem.ToString & cboKlasLetter.SelectedItem.ToString.PadRight(5)

    data.number = CInt(txtNumber.Text)
    data.name = txtName.Text
    data.Bday = CInt(txtBday.Text)
    data.perc = CDec(txtPerc.Text)


    lstOutput.Items.Add(data)

有人能帮我吗?

4

1 回答 1

2

更改字符串 76,50 而不是 07650。

Dim n as Integer = val("07650")

Dim s as String = format(s/100)

这是可选的...

s = s.Replace(".",",") 
s = s.PadRight(5,"0")  

关于您的代码:

它应该是

Return comboboxvalue & nummer.ToString.PadLeft(5) & naam.PadLeft(5) & Geboortejaar.ToString.PadRight(5) & format(perc / 100,"#0.00")
于 2013-06-08T22:51:29.660 回答