展开全部
可以利用msgbox 实现,也可以通过另外的窗体上画出表格实现
方法一,利用msgbox:
Private Sub Command1_Click()Dim a As Long, b As Long, c As LongMsgBox "┌────┬────┬────┐" & vbCrLf _ & "│ 库存1 │ 库存2 │ 库存3 │" & vbCrLf _ & "├────┼────┼────┤" & vbCrLf _ & "│" & formatstr(a) & "│" & formatstr(b) & "│" & formatstr(c) & "│" & vbCrLf _ & "└────┴────┴────┘" End SubPrivate Function formatstr(ByVal inputStr As String) As StringDim j As Integerj = (8 - Len(inputStr)) \ 2formatstr = Space(j) & inputStr & Space(j) & Space((8 - Len(inputStr)) Mod 2)End Function
方法二,利用窗体实现:
’新建form2窗体‘将以下代码复制到form2窗体中Private Sub Form_Load()ShowPrint "┌────┬────┬────┐" & vbCrLf _ & "│ 库存1 │ 库存2 │ 库存3 │" & vbCrLf _ & "├────┼────┼────┤" & vbCrLf _ & "│" & formatstr(a) & "│" & formatstr(b) & "│" & formatstr(c) & "│" & vbCrLf _ & "└────┴────┴────┘" End SubPrivate Function formatstr(ByVal inputStr As String) As StringDim j As Integerj = (8 - Len(inputStr)) \ 2formatstr = Space(j) & inputStr & Space(j) & Space((8 - Len(inputStr)) Mod 2)End Function‘将以下代码复制在form1窗体中Private Sub Command1_Click()Form2.ShowEnd Sub
方法一,利用msgbox:
Private Sub Command1_Click()Dim a As Long, b As Long, c As LongMsgBox "┌────┬────┬────┐" & vbCrLf _ & "│ 库存1 │ 库存2 │ 库存3 │" & vbCrLf _ & "├────┼────┼────┤" & vbCrLf _ & "│" & formatstr(a) & "│" & formatstr(b) & "│" & formatstr(c) & "│" & vbCrLf _ & "└────┴────┴────┘" End SubPrivate Function formatstr(ByVal inputStr As String) As StringDim j As Integerj = (8 - Len(inputStr)) \ 2formatstr = Space(j) & inputStr & Space(j) & Space((8 - Len(inputStr)) Mod 2)End Function
方法二,利用窗体实现:
’新建form2窗体‘将以下代码复制到form2窗体中Private Sub Form_Load()ShowPrint "┌────┬────┬────┐" & vbCrLf _ & "│ 库存1 │ 库存2 │ 库存3 │" & vbCrLf _ & "├────┼────┼────┤" & vbCrLf _ & "│" & formatstr(a) & "│" & formatstr(b) & "│" & formatstr(c) & "│" & vbCrLf _ & "└────┴────┴────┘" End SubPrivate Function formatstr(ByVal inputStr As String) As StringDim j As Integerj = (8 - Len(inputStr)) \ 2formatstr = Space(j) & inputStr & Space(j) & Space((8 - Len(inputStr)) Mod 2)End Function‘将以下代码复制在form1窗体中Private Sub Command1_Click()Form2.ShowEnd Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询