偶是菜鸟^_^,现在需要搞个程序,老板崔的紧,程序功能很简单,程序要求实现:有4个字段,为1、商家号(4位),2、帐号(5位),3、客户号(6位),4、客户名称(3位)。输入以上信息后,按确认后生成txt文件,txt文件中每个字段用tab键分隔,每个字段不能为空,可以用0补齐。
例如:4444 55555 666666 333
可以对生成的txt进行修改,保存。希望各位大虾帮忙哦,小弟感激不尽~~~~~~~~~~~~~~~~感动ing
例如:4444 55555 666666 333
可以对生成的txt进行修改,保存。希望各位大虾帮忙哦,小弟感激不尽~~~~~~~~~~~~~~~~感动ing
type typename
'定义字段
.
.
.
end type
然后打开随即文件写入一条记录就行了。
用ASCII的码写空格
其实很简单啥老板给你好多钱吗
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