偶是菜鸟^_^,现在需要搞个程序,老板崔的紧,程序功能很简单,程序要求实现:有4个字段,为1、商家号(4位),2、帐号(5位),3、客户号(6位),4、客户名称(3位)。输入以上信息后,按确认后生成txt文件,txt文件中每个字段用tab键分隔,每个字段不能为空,可以用0补齐。
例如:4444        55555        666666        333
可以对生成的txt进行修改,保存。希望各位大虾帮忙哦,小弟感激不尽~~~~~~~~~~~~~~~~感动ing

解决方案 »

  1.   

    用一个记录写到文件里
    type typename
         '定义字段
         .
         . 
         .
    end type
    然后打开随即文件写入一条记录就行了。      
      

  2.   

    用FSO对象写TXT文件
    用ASCII的码写空格
    其实很简单啥老板给你好多钱吗
      

  3.   

    '在窗体中添加四个文本框,一个按钮。
    Option Explicit
    '商家号(4位),2、帐号(5位),3、客户号(6位),4、客户名称(3位)。
    Private Type MyType
            strBusID As String * 4
            strAccountID As String * 5
            strCustomerID As String * 6
            strCustomerName As String * 3
    End TypePrivate Function AppendDataToFile(ByVal strFile As String, tData As MyType)
        Dim lFN As Long
        Dim strT As String, strSpace As String
        
        lFN = FreeFile
        strSpace = Space(8)
        With tData
            strT = .strBusID & strSpace
            strT = strT & .strAccountID & strSpace
            strT = strT & .strCustomerID & strSpace
            strT = strT & .strCustomerName
        End With
        Open strFile For Append As #lFN
                Print #lFN, strT
        Close #lFN
    End FunctionPrivate Sub Command1_Click()
        Dim tData As MyType
        
        With tData
            .strBusID = Me.Text1.Text
            .strAccountID = Me.Text2.Text
            .strCustomerID = Me.Text3.Text
            .strCustomerName = Me.Text4.Text
        End With
        Call AppendDataToFile("C:\111.txt", tData)
    End Sub
      

  4.   

    再请教大家一个问题:添加对已生成的txt的读取和修改保存!谢了~~~~~~~~~~~~