Vb.net 2012を使ったソフトです。OricoからのcsvデータとMoneyからのエクスポートデータを比較する機能をもたせています。
今まで、手作業で、一致するか確認していたのが、時間短縮なりそうです。
一致したデータは、別のtextboxに移動させるようにしています。
Public Class Form1
'実行ファイルまたはそのショートカットに、2つのcsvファイル(MoneyからのエクスポートデータとOricoからのcsvデータ)を一緒にドラッグ&ドロップすると、起動して使用できる。
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim files As String() = System.Environment.GetCommandLineArgs()
If files.Length > 1 Then
TextBox1.Text = "" : TextBox2.Text = ""
TextBox1.Text = files(1)
TextBox2.Text = files(2)
Dim enc As System.Text.Encoding = System.Text.Encoding.GetEncoding("shift_jis")
TextBox4.Text = trim(My.Computer.FileSystem.ReadAllText(TextBox1.Text, enc))
TextBox5.Text = trim(My.Computer.FileSystem.ReadAllText(TextBox2.Text, enc))
Else
End If
End Sub
Private Function trim(st As String) As String
Dim tmp() As String
trim = ""
tmp = st.Split(vbCrLf)
Dim sst(), a, b, c, d, e As String
For i = 0 To tmp.Length - 1
e = ""
Try
sst = tmp(i).Split(",")
a = sst(0) : b = sst(1) : e = (sst(8) + sst(9)).Replace("\", "").Replace("""", "")
Catch ex As Exception
'もういっぽうのエクセルデータならよめるはず
Try
sst = tmp(i).Split(",")
b = sst(1) : c = sst(2) : d = sst(4).Replace(".0000", "").Replace("-", "")
Catch ex2 As Exception
Continue For
End Try
trim = trim + b + "," + c + "," + d + vbCrLf
Continue For
End Try
trim = trim + a + "," + b + "," + e + vbCrLf
Next
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim st, tmp1(), tmp2() As String
st = TextBox4.Text
tmp1 = st.Split(vbCrLf)
Dim r1(tmp1.Length) As String
Dim r1flg(tmp1.Length) As Boolean
For i = 0 To tmp1.Length - 1
r1(i) = tmp1(i)
Next
st = TextBox5.Text
tmp2 = st.Split(vbCrLf)
Dim r2(tmp2.Length) As String
Dim r2flg(tmp2.Length) As Boolean
For i = 0 To tmp2.Length - 1
r2(i) = tmp2(i)
Next
Dim tmpx1(), tmpx2() As String
TextBox3.Text = ""
For i = 0 To tmp1.Length - 1
r1flg(i) = True
Next
For i = 0 To tmp2.Length - 1
r2flg(i) = True
Next
For i = 0 To tmp1.Length - 1
For j = 0 To tmp2.Length - 1
If r1flg(i) = False Or r2flg(j) = False Then
Else
Try
tmpx1 = r1(i).Split(",")
tmpx2 = r2(j).Split(",")
' MsgBox(tmpx1(2) + "?" + tmpx2(2))
If Val(tmpx1(2)) = Val(tmpx2(2)) Then
Dim reps As New String(" "c, 6 - tmpx1(2).Length)
TextBox3.Text = TextBox3.Text + reps + tmpx1(2) + " <-" + tmpx1(0) + "_" + tmpx1(1) + "=" + tmpx2(0) + "_" + tmpx2(1) + vbCrLf
r1flg(i) = False : r2flg(j) = False
End If
Catch ex As Exception
End Try
End If
Next
Next
TextBox4.Text = ""
For i = 0 To tmp1.Length - 1
If r1flg(i) = True Then
TextBox4.Text = TextBox4.Text + r1(i) + vbCrLf
End If
Next
TextBox5.Text = ""
For i = 0 To tmp2.Length - 1
If r2flg(i) = True Then
TextBox5.Text = TextBox5.Text + r2(i) + vbCrLf
End If
Next
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
'sortingの機能
Dim st, tmp1(), tmp As String
st = TextBox3.Text
tmp1 = st.Split(vbCrLf)
Dim r1(tmp1.Length) As String
For i = 0 To tmp1.Length - 1
r1(i) = tmp1(i)
Next
For i = 0 To tmp1.Length - 1
For j = i + 1 To tmp1.Length
If r1(i) > r1(j) Then
tmp = r1(i)
r1(i) = r1(j)
r1(j) = tmp
End If
Next
Next
TextBox3.Text = ""
For i = 0 To tmp1.Length - 1
TextBox3.Text = TextBox3.Text + r1(i) + vbCrLf
Next
End Sub
End Class
ネットにアクセスして正規表現を駆使してデータを取り込みつつ、自分の入力したデータを比較できるような家計簿ソフトであればさらに効率的なんですが。
0 件のコメント:
コメントを投稿