
正文
关于vb.net格式输出的信息
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
vb.net 输出 excel
这里有段VB6.0的,你可以参考。
注意添加引用。
Private Sub Command6_Click()
Dim i, j As Integer
Dim xlApplication As Excel.Application, xlWorkbook As Excel.Workbook, xlSheet
Dim xlApp As Excel.Application
On Error Resume Next
Set xlApplication = GetObject(, "Excel.Application")
Set xlApp = CreateObject("Excel.Application")
If MsgBox("确认将文件信息导出到EXCEL中?�", vbExclamation + vbYesNo, "警告") = vbYes Then
If Err.Number 0 Then Set xlApplication = CreateObject("Excel.Application")
Set xlWorkbook = xlApplication.Workbooks.Add
Set xlSheet = xlWorkbook.ActiveSheet
xlSheet.Cells(1, 2) = lblcl.Caption
xlSheet.Range("A1:E1").MergeCells = True
xlSheet.Range("A1:E1").HorizontalAlignment = xlCenter
xlSheet.Cells(2, 2).ColumnWidth = 18
For i = 1 To DataGrid1.Columns.Count
xlSheet.Cells(2, 1) = "编号"
xlSheet.Cells(2, i + 1) = DataGrid1.Columns(i).Caption
For j = 0 To DataGrid1.VisibleRows - 1
xlSheet.Cells(j + 3, 1) = j + 1
xlSheet.Cells(j + 3, i + 1) = DataGrid1.Columns(i).CellText(DataGrid1.RowBookmark(j))
Next j
Next i
xlApplication.Visible = True
Set xlSheet = Nothing
Set xlWorkbook = Nothing
Set xlApplication = Nothing
'xlApp.Range("A2:L2").Columns.Interior.ColorIndex = 40
'xlApp.Range("A2:L2").Borders.LineStyle = xlContinuous
'xlApp.Visible = True
'xlApp.Range(xlSheet.Cells(2 + PartsRs.RecordCount + 1, 1), xlSheet.Cells(2 + PartsRs.RecordCount + 1, 8)).Columns.Interior.ColorIndex = 40
'xlApp.Range(xlSheet.Cells(2 + PartsRs.RecordCount + 1, 1), xlSheet.Cells(2 + PartsRs.RecordCount + 1, 8)).Borders.LineStyle = xlContinuous
Else
MsgBox "无信息可供您导出,请确认!", vbExclamation + vbOKOnly, "警告"
End If
End Sub
相关问答
Q1: 【VB.net】Datatimepick控件输出格式为Date
如果a是数值字串可以直接进行后面计算而无需转换。
Dim a As String
a = "50"
Debug.Print a * 10
Q2: vb.net 如何用format转换小数成整数
直接用int就可以了。
int(2310.125)=2310
如果需要自定义格式输出,就要用tostring方法vb.net格式输出,比如:
2310.231.tostring("0")vb.net格式输出的结果就是2310。
如果你要去掉个位数,看来只有(2310.231/10).tostring("0")了。
详细的ToString里面的参数,请看MSDN。我查了一下,有,地址是:
Q3: 如何在vb.net控制台程序中格式化输出结果(如图)
Sub Main()
Dim a As Boolean = True, b As Boolean = False
Console.WriteLine(LCase("a=" a " b=" b))
Console.WriteLine(LCase("true and false = " (a And b)))
Console.WriteLine(LCase("true and not false = " (a And Not b)))
Console.WriteLine(LCase("true false or false = " ((ab) Or b)))
Console.ReadKey()
End Sub
Q4: VB.NET格式输出函数format怎么用?
果在格式化数字时没有指定 format,Format 会提供与 Str 函数类似的功能
' 如果没有指定格式,则返回字符串。
MyStr = Format(23) ' 返回 "23"。
' 用户自定义的格式。
MyStr = Format(5459.4, "##,##0。00") ' 返回 "5,459.40"。
MyStr = Format(334。9, "###0。00") ' 返回 "334.90"。
MyStr = Format(5, "0。00%") ' 返回 "500.00%"。
MyStr = Format("HELLO", "") ' 返回 "hello"。
MyStr = Format("This is it", "") ' 返回 "THIS IS IT
Q5: 用VB.NET编一个窗体程序 将程序结果输出为文档格式
写入txt文档vb.net格式输出的方法vb.net格式输出,需要一个参数作为写入vb.net格式输出的字符串:
Private Sub WriteDoc(ByVal wstring As String)
Using sw As New StreamWriter(Application.StartupPath "\output.txt", True)
sw.Write(wstring)
End Using
End Sub
vb.net格式输出的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于、vb.net格式输出的信息别忘了在本站进行查找喔。






