需要一个程序来从vb中读取数据写入到外部文件中
小弟需要一个小程序,恳求高手帮忙.感激不尽!具体要求如下:
需要由3个textbox一组的数据,如:text1;text2;text3,这3个数据都是有规定字数的,
现在以每组数据都是15位字母或数字组成,采集text1的15位之后需要autotab到text2,
采集text2的15位数据之后要autotab到text3;text3的数据采集完毕之后,需要自动将数据
写入到e:\tsd.txt文件!写入格式为:
tsdxuliehao``"text1"``text2"
tsdxuliehao``"text1"``text3"
( 要分行写入,同一批次的“tsdxuliehao”一样,对于不同批次,需要修改“tsdxuliehao”)
写入后再重新自动Tab到text1采集另一组数据
loop
我需要的txt为:
tsdxuliehao``"text1"``"text2"
tsdxuliehao``"text1"``"text3"
tsdxuliehao``"text1"``"text2"
tsdxuliehao``"text1"``"text3"
tsdxuliehao``"text1"``"text2"
tsdxuliehao``"text1"``"text3"
……
……
……
……
tsdxuliehao``"text1"``text2"
tsdxuliehao``"text1"``text3"
每行前面有行号最好!导出的文件用excel格式也行!
谢谢各位大侠!
email:yxjanddy@163.com --------------------编程问答-------------------- tsdxuliehao是什么?写入文件时是"tsdxuliehao"字符还是代号?``号要吗?
其实这个程序很简单,自己做吧。 --------------------编程问答-------------------- tsdxuliehao是代号,每一个批次的都是一样的,换批次的话需要自己手动改动
``还是要的!
楼上的,我是菜鸟啊,就没有学过语言,帮忙做一个吧! --------------------编程问答-------------------- VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3465
ClientLeft = 60
ClientTop = 450
ClientWidth = 5430
LinkTopic = "Form1"
ScaleHeight = 3465
ScaleWidth = 5430
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "写入文件"
Height = 375
Left = 1800
TabIndex = 8
Top = 2640
Width = 1875
End
Begin VB.TextBox Text3
Height = 315
Left = 1860
MaxLength = 15
TabIndex = 7
Top = 1860
Width = 2655
End
Begin VB.TextBox Text2
Height = 315
Left = 1860
MaxLength = 15
TabIndex = 5
Top = 1500
Width = 2655
End
Begin VB.TextBox Text1
Height = 315
Left = 1860
MaxLength = 15
TabIndex = 3
Top = 1080
Width = 2655
End
Begin VB.TextBox Text0
Height = 315
Left = 1860
TabIndex = 1
Top = 660
Width = 2655
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Caption = "text3"
Height = 255
Index = 3
Left = 900
TabIndex = 6
Top = 1980
Width = 915
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Caption = "text2"
Height = 255
Index = 2
Left = 900
TabIndex = 4
Top = 1560
Width = 915
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Caption = "text1"
Height = 255
Index = 1
Left = 900
TabIndex = 2
Top = 1140
Width = 915
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Caption = "批次代号"
Height = 255
Index = 0
Left = 900
TabIndex = 0
Top = 720
Width = 915
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Open "e:\tsd.txt" For Append As #1
Print #1, Text0 & "``" & Chr(34) & Text1 & Chr(34) & "``" & Chr(34) & Text2 & Chr(34)
Print #1, Text0 & "``" & Chr(34) & Text1 & Chr(34) & "``" & Chr(34) & Text3 & Chr(34)
Close #1
End Sub
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
If Len(Text1) = Text1.MaxLength Then Text2.SetFocus
End Sub
Private Sub Text2_KeyUp(KeyCode As Integer, Shift As Integer)
If Len(Text2) = Text2.MaxLength Then Text3.SetFocus
End Sub
Private Sub Text3_KeyUp(KeyCode As Integer, Shift As Integer)
If Len(Text3) = Text3.MaxLength Then Command1 = True
End Sub --------------------编程问答-------------------- 我直接编译了,奇怪的是我的防毒软件居然误报说是病毒 stup.worm 病毒,真奇怪,你试试
--------------------编程问答-------------------- 改进版
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3465
ClientLeft = 60
ClientTop = 450
ClientWidth = 5430
LinkTopic = "Form1"
ScaleHeight = 3465
ScaleWidth = 5430
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "写入文件"
Height = 375
Left = 1800
TabIndex = 8
Top = 2640
Width = 1875
End
Begin VB.TextBox Text
Height = 315
Index = 3
Left = 1860
MaxLength = 15
TabIndex = 7
Top = 1860
Width = 2655
End
Begin VB.TextBox Text
Height = 315
Index = 2
Left = 1860
MaxLength = 15
TabIndex = 5
Top = 1500
Width = 2655
End
Begin VB.TextBox Text
Height = 315
Index = 1
Left = 1860
MaxLength = 15
TabIndex = 3
Top = 1080
Width = 2655
End
Begin VB.TextBox Text
Height = 315
Index = 0
Left = 1860
TabIndex = 1
Top = 660
Width = 2655
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Caption = "text3"
Height = 255
Index = 3
Left = 900
TabIndex = 6
Top = 1980
Width = 915
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Caption = "text2"
Height = 255
Index = 2
Left = 900
TabIndex = 4
Top = 1560
Width = 915
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Caption = "text1"
Height = 255
Index = 1
Left = 900
TabIndex = 2
Top = 1140
Width = 915
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Caption = "批次代号"
Height = 255
Index = 0
Left = 900
TabIndex = 0
Top = 720
Width = 915
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim s As String
s = Text(0) & "``" & Chr(34) & Text(1) & Chr(34) & "``"
Open "e:\tsd.txt" For Append As #1
Print #1, s & Chr(34) & Text(2) & Chr(34)
Print #1, s & Chr(34) & Text(3) & Chr(34)
Close #1
' MsgBox "已写入文件"
End Sub
Private Sub Text_GotFocus(Index As Integer)
With Text(Index)
.SelStart = 0
.SelLength = Len(.Text)
End With
End Sub
Private Sub Text_KeyUp(Index As Integer, KeyCode As Integer, Shift As Integer)
If Index = 0 And KeyCode = 13 Then Text(1).SetFocus
If Len(Text(Index)) = Text(Index).MaxLength Then
If Index = 3 Then
Command1.Value = 1
Text(1).SetFocus
Text(1) = "": Text(2) = "": Text(3) = ""
Else
Text(Index + 1).SetFocus
End If
End If
End Sub --------------------编程问答-------------------- 谢谢了,怎么给你加分! --------------------编程问答-------------------- 题目没看懂... --------------------编程问答-------------------- 不明LZ在说什么 --------------------编程问答-------------------- 有问题请先GOOGLE,BAIDU
补充:VB , 数据库(包含打印,安装,报表)