セルを作るのにvb 6.0を使うとき、数が1-9で終わらないならば、我々は小数点の後に2桁で量が表示されることを強制することはできません。例えば59.12は正しく表示されますが、59.10を試すとセルに59.1が表示されます。さまざまな形式やテキスト出力を試してみましたが成功しませんでした。
以下で試したことに答えて、私たちが試してみたコードの一部が最も注目されています。
StartForm:
ActiveWorkbook.Styles.Add(Name:="NelcoAmt").NumberFormat = "#.00"
'ActiveWorkbook.Styles("Number").NumberFormat = "######.00"
'ActiveWorkbook.Styles("Number").Application.FixedDecimalPlaces = 2
'ActiveWorkbook.Styles("Currency").Application.Caption = ""
'ActiveWorkbook.Styles("Currency").IncludePatterns = False
'ActiveWorkbook.Styles("Currency").Application. = ""
'ActiveWorkbook.Styles("Currency").Application.
'xlSheet.Cells(1, 34).NumberFormat = "@"
'xlSheet.Cells(2, 34).NumberFormat = "#.00"
'xlSheet.Cells(2, 34).Format = "#.00"
ActiveWorkbook.Styles("NelcoAmt").Application.FixedDecimalPlaces = 2
xlSheet.Cells(2, 34).Style = "NelcoAmt": '.NumberFormat = "#.00": 'Number
'For i% = 1 To ActiveWorkbook.Styles.Count
'Text$ = ActiveWorkbook.Styles(i%).Name
'xlSheet.Cells(i%, 1).Style = Text$
'xlSheet.Cells(i%, 1).Value = 59.4
'xlSheet.Cells(i%, 2).Value = Text$
'Next i%
Rem-----9/15/14---set header for variables
xlSheet.Cells(1, 1).Value = "UniqueFormKey"
xlSheet.Cells(1, 2).Value = "FormName"
xlSheet.Cells(1, 3).Value = "OR_EFIN"
xlSheet.Cells(1, 4).Value = "OR_Type"
Rem======================================start of test section
Dim NumAns As Double
'7/16/15
'NumAns = Format$(Format$(Val(Frm941Inp.Scr941(19)), "########.00"), "@@@@@@@@@@@")
txtOut = Format$(Format$(Val(Frm941Inp.Scr941(19)), "########.00"), "@@@@@@@@@@@")
'NumAns = FormatNumber((Val(Frm941Inp.Scr941(19))), 2)
NumAns = Val(Frm941Inp.Scr941(19))
If Val(Frm941Inp.Scr941(18)) = 0 Then txtOut = "0.00"
txtOut = Frm941Inp.Scr941(19)
'xlSheet.Cells(2, 34).NumberFormat = "@": ' = txtOut: '"########.00"]
'xlSheet.Cells(2, 34) = (FormatNumber(Val(Frm941Inp.Scr941(19)), 2), "text"): 'txtOut ', "########.00"): '5d 2 tax on add medi wage
'xlSheet.Cells(2, 34) = "'" & FormatNumber(Val(Frm941Inp.Scr941(19)), 2): 'txtOut ', "########.00"): '5d 2 tax on add medi wage
'txtOut = "'" & txtOut
xlSheet.Cells(2, 34).Style.NumberFormat = "#.00": 'Number
xlSheet.Cells(2, 34) = Format(NumAns, "#.00"): 'txtOut: 'Val(Frm941Inp.Scr941(19)): 'txtOut ', "########.00"): '5d 2 tax on add medi wage
'xlSheet.Cells(2, 34).Style.NumberFormat = "#.00": 'Number
'xlSheet.Cells(2, 34).NumberFormat = "#.00"
'xlSheet.Cells(2, 34).Value = Val(Frm941Inp.Scr941(19))
'xlSheet.Cells(2, 34).value = FormatNumber(Val(Frm941Inp.Scr941(19)), 2): '"#######.00")
'xlSheet.Cells(2, 34).Value = Format$(Format$(Val(Frm941Inp.Scr941(19)), "########.00"), "@@@@@@@@@@@")
'xlSheet.Cells(2, 34).Value = Val(Frm941Inp.Scr941(19)): '5d 2 tax on add medi wage
Rem===================================end of test section=================================================
数字に表示される小数点以下の桁数を変更する
—
DavidPostill