vb6 - Replacing a filename problem? -


Use of VB6

In a folder, there is a number of text files, the file name is similar to abc. Mis-.txt, def.fin @ .txt, so I want to rename the filenames like abcmis.txt, deffin.txt. I used a function to change the name.

code

  String file name 3 as 3-Dir $ (txtSourceDatabaseFile and "\ * .txt", vb directory), while filename 3 & lt; & Gt; "" Function to rename " 
  String dim strutput as string dimension stroke as string dimension structure as string dim intChhar as integer dim intro like integer strInput = filename3 IntLoop = 1 for strings (strInput) = mer $ (strInput, intLoop, 1) intChar = asc (strChar) if ((intChar> = 48) and (intChar & lt; = 57) or _ ((intChar & Gt; = 65) and (the initials  = 97) and (intChar & lt; = 122)) or _ (intChar = 95) then the strutput = strutput & strchar end If jugal The name txtSourceDatabaseFile & amp; "\" & amp; filename3 = Dir $ Loop  

txtSourceDatabaseFile & amp; "\" & amp; The above coding is working, the problem is being used during the conditon, so it will rename all the txt files, this name is preferred

for example.

 For the first time in the "stroutput", giving the filename as ABS is the second time giving a filename as "abcdef" in the "strutput" ...,  

A previous filename Mr. add, because to get the file name in the loop.

How to modify my code.

  Private Function GetTextOnlyFileName (string as Walt Strongel string) string string string as string stratum in the form of string dimension strings as string dimension integer in the form of integer dim intro For InteLoop = 1 lane (strOldName) strChar = Mid $ (strOldName, intLoop, 1) intChar = Asc StrChar) ((intChar> = 48) and (int four and lt; = 57)) or _ (intChar = 65) and (intChar & lt; = 90)) or _ ((intChar> = 97) and (intChar & lt; = 122)) or _ (intChar = 95) then the stratimp = stratum & amp;  

Then use something like this to get a new file name:

  while the filename 3 & lt; & Gt; "StrNewName = GetTextOnlyFileName (strFileName3) Get the name of the name of the next file named 'strNewName'. However, if you rename two different source filenames then what do you do? For example, for example, abc@def.txt and ab @ cd @ ef.txt will return the same thing. 

Your code is currently adding the file name because you are From the same variables are reusing and without clearing the pre-values ​​again In form. Will work my function, but you line strOutPut = "line strInput = just add after filename3 and should work it.


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -