Skip to content

Instantly share code, notes, and snippets.

@toagit
toagit / Sync.vbs
Created January 12, 2016 05:21
DOSコマンド非同期・同期サンプル
' * 実行中のプログラムのハンドルを取得
' *
Private Declare Function OpenProcess Lib "kernel32" ( _
ByVal Access As Long _
, ByVal Handle As Long _
, ByVal taskId As Long _
) As Long
' *
@toagit
toagit / ErrorProcess.vbs
Created November 20, 2015 06:03
例外処理
Sub Sample()
Dim buf As String
On Error GoTo myError
Open "C:\Sample.dat" For Input As #1
Line Input #1, buf
Range("A1") = buf
Close #1
Worksheets("Sheet2").Name = "合計"
Exit Sub
ErrorHandler1:
@toagit
toagit / xlsUnlock.vbs
Created July 14, 2015 00:58
エクセルパスワード解除vbスクリプト
Option Explicit
Dim max
Dim min
'===============================================================================
':: 最大(max)・最小(min)のパスワード長を設定してください
max = 10
min = 3
'===============================================================================
':: ここから下はいぢらないでください
@toagit
toagit / build.xml
Last active October 4, 2016 12:24
ant build sample. contain javac, javadoc, zip.
<?xml version="1.0" encoding="Windows-31J"?>
<project name="builSample" default="main" basedir=".">
<property name="path.lib" location="./lib"/>
<property name="path.out" location="./dest"/>
<property name="path.bin" location="${path.out}/bin"/>
<property name="path.src" location="./src"/>
<property name="path.test" location="./srctest"/>
<property name="path.doc" location="${path.out}/javadoc"/>
<property name="compiler" value="JAVA_HOME\bin\javac"/>
@toagit
toagit / AbstractMainTester.java
Last active April 3, 2017 09:35
mainメソッドのJUnitサンプル。System.Exitのコードの確認。標準出力(System.out、System.Err)の取得。
/**
* mainメソッド実装クラスをテストする基底クラス。
*/
public abstract class AbstractMainTester {
private static final String ARGS_DELIMITER = " ";
protected static final String LINE_SEPARATOR = System.getProperty("line.separator");
private static final PrintStream stdOut = System.out;
private static final PrintStream stdErr = System.err;
private static final SecurityManager securityManager = System.getSecurityManager();
@toagit
toagit / SampleMain.java
Created July 9, 2015 03:52
javaの実行可能クラスの雛形。CLIからの呼び出し用。
/**
* 実行可能クラス雛形
*/
public class SampleMain() {
private boolean readyToRun = false;
private String sampleValue = "";
/**
* コンストラクタ
@toagit
toagit / ActivateA1.vbs
Last active December 22, 2020 20:01
指定したファイルの全てのシートについてA1セルをActiveにするスクリプト
Option Explicit
'/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
'指定したエクセルファイルの全てのシートのセルをA1セルへ移動するスクリプト
'エクセルの指定はダイアログ、D&Dをサポート
'/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
Call ActivateA1
Private Sub ActivateA1()
@toagit
toagit / CreateFolder.vbs
Last active December 15, 2015 01:21
階層フォルダを作成するVBスクリプト
Option Explicit
CreateFolder
Private Sub CreateFolder()
Dim path
' path = "C:\CreTest\a\b\c"
path = InputBox("作成するフォルダを入力してください。",,Replace(WScript.ScriptFullName,WScript.ScriptName,""))
Dim objExcel
@toagit
toagit / xlsFileMarge.vbs
Last active August 29, 2022 09:54
複数のExcelファイルを1ファイルにまとめるVBScript
Option Explicit
Const msoFileDialogFolderPicker = 4
Const EXTENSION = ".xlsx"
Call MargeSheet
'Excelファイルマージ
Sub MargeSheet()
Dim scriptPath
@toagit
toagit / GetSysout.java
Last active August 29, 2015 14:24
標準出力の取得
PrintStream source = System.out;
ByteArrayOutputStream out = new ByteArrayOutputStream();
System.setOut(new PrintStream(out));
// version < java7
assertEquals("expect" + System.getProperty("line.separator"),out.toString());
// version >= java7
assertEquals("expect" + System.lineSeparator,out.toString());