3 Replies - 2490 Views - Last Post: 13 October 2008 - 08:22 AM Rate Topic: -----

#1 shamsam1   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 4
  • Joined: 29-February 08

retrive vlaue from bat file and inset in textbox vb.6

Post icon  Posted 13 October 2008 - 05:44 AM

i need to retrieve value from bat file and place the path in textbox.
i have 3 forms and per form 4 textbox

i want to use vb.6 code to do retrieve the values..
text1,text2,text3,text4 in form 1

text1.text=d:\folder1\Images\10.dwg
text2.text=d:\folder1\Images\11.dwg
text3.text=e:\folder3\Images\13.dwg
text4.text=e:\folder3\Images\14.dwg

and text5.text,text6,text7 in form 2
text5.text=e:\folder3\Images\15.dwg
text6.text=e:\Images\16.dwg
text7.text=f:\18.dwg;

ex in bat file
C:\Documents and Settings\Desktop\DWG6\IMAGE.exe d:\folder1\Images\10.dwg;d:\folder1\Images\11.dwg;e:\folder3\Images\13.dwg; e:\folder3\Images\14.dwg;e:\folder3\Images\15.dwg;e:\Images\16.dwg;f:\18.dw g;dim:off;sin:off;syd:on

Is This A Good Question/Topic? 1

Replies To: retrive vlaue from bat file and inset in textbox vb.6

#2 PsychoCoder   User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1659
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: retrive vlaue from bat file and inset in textbox vb.6

Posted 13 October 2008 - 05:53 AM

[rules][/rules]
Was This Post Helpful? 0
  • +
  • -

#3 shamsam1   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 4
  • Joined: 29-February 08

Re: retrive vlaue from bat file and inset in textbox vb.6

Posted 13 October 2008 - 06:39 AM

Dim nFileNum As Integer, sText As String, sNextLine As String, lLineCount As Long

'==================================

Private Sub Command1_Click()

Dim strInputString      As String
    Dim strFilterText       As String
    Dim astrSplitItems()    As String
    Dim astrFilteredItems() As String
    Dim strFilteredString   As String
    Dim intX                As Integer

' Get a free file number
nFileNum = FreeFile

' Open a text file for input. inputbox returns the path to read the file
Open "C:\1.txt" For Input As nFileNum
lLineCount = 1
' Read the contents of the file
Do While Not EOF(nFileNum)
   Line Input #nFileNum, sNextLine
   'do something with it
   'add line numbers to it, in this case!
   sNextLine = sNextLine & vbCrLf
   sText = sText & sNextLine

Loop

'strInputString = InputBox("Enter a comma-delimited string of items:", _
                              "String Array Functions")
                              
           strInputString = sText
   ' strFilterText = InputBox("Enter Filter:", "String Array Functions")
    
   ' Print "Original Input String: "; strInputString
   ' Print
    
  ' Print "Split Items:"
    astrSplitItems = Split(strInputString, ";")
    For intX = 0 To UBound(astrSplitItems)
     'Print "item("; intX; "): "; astrSplitItems(intX)
     Text1.Text = astrSplitItems(1)
     Text2.Text = astrSplitItems(2)
     Text3.Text = astrSplitItems(3)
     Text4.Text = astrSplitItems(4)
        Next
'Text1.Text = sText

' Close the file
Close nFileNum

End Sub



Mod Edit: Please use code tags when posting your code. Code tags are used like so => :code:

Thanks,
PsychoCoder :)
Was This Post Helpful? 0
  • +
  • -

#4 thava   User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,607
  • Joined: 17-April 07

Re: retrive vlaue from bat file and inset in textbox vb.6

Posted 13 October 2008 - 08:22 AM

try this
Dim nFileNum As Integer, sText As String, sNextLine As String, lLineCount As Long

'==================================

Private Sub Command1_Click()

Dim strInputString      As String
    Dim strFilterText       As String
    Dim astrSplitItems()    As String
    Dim astrFilteredItems() As String
    Dim strFilteredString   As String
    Dim intX                As Integer

' Get a free file number
nFileNum = FreeFile

' Open a text file for input. inputbox returns the path to read the file
Open "C:\1.txt" For Input As nFileNum
lLineCount = 1
' Read the contents of the file
Do While Not EOF(nFileNum)
   Line Input #nFileNum, sNextLine
   'do something with it
   'add line numbers to it, in this case!
   sNextLine = sNextLine & vbCrLf
'*************Corrected Line
   sText = sText & "," & sNextLine
'*************Corrected Line

Loop

'strInputString = InputBox("Enter a comma-delimited string of items:", "String Array Functions")
                              
           strInputString = sText
   ' strFilterText = InputBox("Enter Filter:", "String Array Functions")
    
   ' Print "Original Input String: "; strInputString
   ' Print
    
  ' Print "Split Items:"
    astrSplitItems = Split(strInputString, ";")
' *********if the file contains only four line then this code is not much wrong
     Text1.Text = astrSplitItems(1)
     Text2.Text = astrSplitItems(2)
     Text3.Text = astrSplitItems(3)
     Text4.Text = astrSplitItems(4)

'*********or else

    For intX = 0 To UBound(astrSplitItems)
     'Print "item("; intX; "): "; astrSplitItems(intX)
     text1(intx).text = astrSplitItems(intX)
        Next
'Text1.Text = sText

' Close the file
Close nFileNum

End Sub



This post has been edited by thava: 13 October 2008 - 08:22 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1