下面是源代码,我的目地是把一个VB的FORM文件读出来然后在适当的地方写一个属性
但是下面的代码问题是当我写完这个文件后,发现被修改后的FORM文件内的格式全都没有了,所有代码全都靠左边了,我想不改变源FORM文件内的代码格式,不知道那位大哥哥有招,pass后马上给分!Dim s As String
Dim fso As New FileSystemObject
Dim Folder As Folder
Dim File As File
Dim intCount As Long
Dim lonLen As Long
Dim strString As String
Dim intFor As Integer
Dim strName As String
Dim strFileName As String
Dim intTempFor As Integer
Set Folder = fso.GetFolder("C:\a\")
   Dim Conn    As ADODB.Connection
    Dim strSQL As String
    
    Dim rs As ADODB.Recordset
    
    Set rs = New ADODB.Recordset
    
   
    ' Get connection and open it
    Set Conn = New ADODB.Connection
    Set Conn = New ADODB.Connection
    
      intCount = intCount + 1For Each File In Folder.Files   '  open  File.Name as intput #1
Open "C:\a\" & File.Name For Binary As #1
    
    lonLen = Len(File.Name)
    strString = Left(File.Name, lonLen - 4)
    strName = Right(File.Name, 4)
    strFileName = File.Name
    Open "C:\a\" & strString & "a" & strName For Output As #2
      '''If File.Name = "frmUDL.frm" Then Exit Sub
        Do Until EOF(1)
            Input #1, s
            Print #2, s
            'Select Case s
             
               If Left(s, 13) = "Begin VB.Form" Then
                  
                  For intTempFor = 0 To 1000
                     If EOF(1) = True Then GoTo nextGO
                     Input #1, s
                     
                     If Left(Trim(s), 10) = "ScaleWidth" Then
                     
                        Print #2, "Tag             =   " & """" & intCount & """"
                        Print #2, s
                        intCount = intCount + 1
                      ElseIf Left(Trim(s), 9) = "Begin VB." Then
                           Print #2, s
                           GoTo next1:
                      Else
                        Print #2, s
                      End If
                      
                  Next intTempFor '''For intTempFor = 0 To 1000
               End If
next1:
               If Left(s, 17) = "Begin VB.CheckBox" Then
               
                  For intTempFor = 0 To 1000
                     Input #1, s
                     If Left(s, 3) = "End" And s <> "EndProperty" Then
                        Print #2, s
                        GoTo nextGO
                        
                     End If '''If Left(s, 3) = "End" Then
                     
                     
                     If Left(Trim(s), 5) = "Width" Then
                         Print #2, "Tag             =   " & """" & intCount & """"
                         Print #2, s
                         intCount = intCount + 1
                     Else
                     
                         Print #2, s
                         
                     End If '''If Left(Trim(s), 5) = "Width" Then
                     
                  Next intTempFor '''For intTempFor = 0 To 1000
               End If
               
               If Left(s, 21) = "Begin VB.OptionButton" Then
                
                   For intTempFor = 0 To 1000
                      Input #1, s
                      If Left(s, 3) = "End" And s <> "EndProperty" Then
                         Print #2, s
                         GoTo nextGO
                         
                      End If '''If Left(s, 3) = "End" Then
                      
                      
                      If Left(Trim(s), 5) = "Width" Then
                          Print #2, "Tag             =   " & """" & intCount & """"
                          Print #2, s
                          intCount = intCount + 1
                      Else
                      
                          Print #2, s
                          
                      End If '''If Left(Trim(s), 5) = "Width" Then
                      
                   Next intTempFor '''For intTempFor = 0 To 1000
                End If
                
                If Left(s, 22) = "Begin VB.CommandButton" Then
                
                   For intTempFor = 0 To 1000
                      Input #1, s
                      If Left(s, 3) = "End" And s <> "EndProperty" Then
                         Print #2, s
                         GoTo nextGO
                         
                      End If '''If Left(s, 3) = "End" Then
                      
                      
                      If Left(Trim(s), 5) = "Width" Then
                          Print #2, "Tag             =   " & """" & intCount & """"
                          Print #2, s
                          intCount = intCount + 1
                      Else
                      
                          Print #2, s
                          
                      End If '''If Left(Trim(s), 5) = "Width" Then
                      
                   Next intTempFor '''For intTempFor = 0 To 1000
                End If
               
                If Left(s, 14) = "Begin VB.Label" Then
                
                   For intTempFor = 0 To 1000
                      Input #1, s
                      If Left(s, 3) = "End" And s <> "EndProperty" Then
                         Print #2, s
                         GoTo nextGO
                         
                      End If '''If Left(s, 3) = "End" Then
                      
                      
                      If Left(Trim(s), 5) = "Width" Then
                          Print #2, "Tag             =   " & """" & intCount & """"
                          Print #2, s
                          intCount = intCount + 1
                      Else
                      
                          Print #2, s
                          
                      End If '''If Left(Trim(s), 5) = "Width" Then
                      
                   Next intTempFor '''For intTempFor = 0 To 1000
                End If
                
                If Left(Trim(s), 14) = "Begin VB.Frame" Then
                
                   For intTempFor = 0 To 1000
                      Input #1, s
                      If Left(s, 3) = "End" And s <> "EndProperty" Then
                         Print #2, s
                         GoTo nextGO
                         
                      End If '''If Left(s, 3) = "End" Then
                      
                      
                      If Left(Trim(s), 5) = "Width" Then
                          Print #2, "Tag             =   " & """" & intCount & """"
                          Print #2, s
                          intCount = intCount + 1
                      Else
                      
                          Print #2, s
                          
                      End If '''If Left(Trim(s), 5) = "Width" Then
                      
                   Next intTempFor '''For intTempFor = 0 To 1000
                End If
nextGO:        Loop '''Do Until EOF(1)
        
    Close #2
    
Close #1
Kill "C:\a\" & strFileName
Name "C:\a\" & strString & "a" & strName As "C:\a\" & strFileNameNext