您的位置:程序门 -> vb -> 数据库(包含打印,安装,报表)



需要一个程序来从vb中读取数据写入到外部文件中


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


需要一个程序来从vb中读取数据写入到外部文件中
发表于:2008-01-17 16:10:31 楼主
小弟需要一个小程序,恳求高手帮忙.感激不尽!
具体要求如下:
需要由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
发表于:2008-01-17 16:50:581楼 得分:0
tsdxuliehao是什么?写入文件时是"tsdxuliehao"字符还是代号?``号要吗?
其实这个程序很简单,自己做吧。
发表于:2008-01-18 09:23:062楼 得分:0
tsdxuliehao是代号,每一个批次的都是一样的,换批次的话需要自己手动改动
``还是要的!
楼上的,我是菜鸟啊,就没有学过语言,帮忙做一个吧!
发表于:2008-01-18 15:12:323楼 得分:0
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
发表于:2008-01-18 15:21:544楼 得分:0
我直接编译了,奇怪的是我的防毒软件居然误报说是病毒   stup.worm   病毒,真奇怪,你试试
发表于:2008-01-18 15:53:525楼 得分:0
改进版
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
发表于:2008-01-21 10:17:086楼 得分:0
谢谢了,怎么给你加分!
发表于:2008-01-21 10:37:027楼 得分:0
题目没看懂...


快速检索

最新资讯
热门点击