Имя пользователя:
Пароль:  
Помощь | Регистрация | Забыли пароль?  

Название темы: VBS. Формат суммы
Показать сообщение отдельно

Ветеран


Сообщения: 27449
Благодарности: 8087

Профиль | Отправить PM | Цитировать


Попробуйте так:
Скрытый текст
Код: Выделить весь код
Option Explicit

Const ForWriting   = 2

Dim strSourceFile
Dim strContent


If WScript.Arguments.Count = 1 Then
	strSourceFile = WScript.Arguments.Item(0)
	
	With WScript.CreateObject("Scripting.FileSystemObject")
		If .FileExists(strSourceFile) Then
			With .OpenTextFile(strSourceFile)
				strContent = .ReadAll()
				.Close
			End With
			
			With WScript.CreateObject("VBScript.RegExp")
				.Global = True
				.Pattern = "0*(\d*)(\d)(\d{2})"
				
				If .Test(strContent) Then
					strContent = .Replace(strContent, "$1$2,$3")
				Else
					WScript.Echo "Can't find pattern [" & .Pattern & "]."
					WScript.Quit 3
				End If
			End With
			
			.CopyFile strSourceFile, strSourceFile & ".bak"
			
			With .OpenTextFile(strSourceFile, ForWriting)
				.Write strContent
				.Close
			End With
		Else
			WScript.Echo "Can't find source file [" & strSourceFile & "]."
			WScript.Quit 2
		End If
	End With
Else
	WScript.Echo "Usage: cscript.exe //nologo """ & WScript.ScriptName & """ <Source file>"
	WScript.Quit 1
End If

WScript.Quit 0

Исходный файл указывается аргументом скрипта. Также можно просто перетянуть исходный файл на скрипт в Проводнике.
Это сообщение посчитали полезным следующие участники:

Отправлено: 04:03, 12-11-2015 | #2

Название темы: VBS. Формат суммы