初期化処理 |
---|
General_Declarations プロシージャ
'セーブデータのフルパス名を格納するための変数 Dim SaveFileName As String 'データ読み込み時に、アイテムを何種類持っていたか Dim ItemNumber As Long |
Form_Load プロシージャ
Private Sub Form_Load() cmdWrite.Enabled = False txtHP.Enabled = False txtMaxHP.Enabled = False txtSTR.Enabled = False txtDEF.Enabled = False txtLUCK.Enabled = False txtSPEED.Enabled = False txtGOLD.Enabled = False For i = 0 To 4 txtITEM(i).Enabled = False Next i End Sub |
セーブデータ読み込み処理 |
---|
cmdRead_Click プロシージャ1
Private Sub cmdRead_Click() 'セーブデータを読み込む With CommonDialog1 .DialogTitle = "コードファイルの選択" .Filter = "セーブデータ(savedata.dat)|savedata.dat|" .Flags = cdlOFNHideReadOnly End With CommonDialog1.ShowOpen If CommonDialog1.FileName <> "" Then SaveFileName = CommonDialog1.FileName Else Exit Sub End If |
cmdRead_Click プロシージャ2
'各データをセーブデータから読み込み、それぞれのボタンを使用可・不可に DataGet cmdRead.Enabled = False cmdWrite.Enabled = True txtHP.Enabled = True txtMaxHP.Enabled = True txtSTR.Enabled = True txtDEF.Enabled = True txtLUCK.Enabled = True txtSPEED.Enabled = True txtGOLD.Enabled = True |
DataGet プロシージャ
Private Sub DataGet() lblName.Caption = HexToDecOrAscii(GetFileData(SaveFileName, "0", "16"), "$2") txtHP.Text = HexToDecOrAscii(GetFileData(SaveFileName, "30", "2"), "M") txtMaxHP.Text = HexToDecOrAscii(GetFileData(SaveFileName, "32", "2"), "M") txtSTR.Text = HexToDecOrAscii(GetFileData(SaveFileName, "38", "2"), "M") txtDEF.Text = HexToDecOrAscii(GetFileData(SaveFileName, "3C", "2"), "M") txtLUCK.Text = HexToDecOrAscii(GetFileData(SaveFileName, "40", "2"), "M") txtSPEED.Text = HexToDecOrAscii(GetFileData(SaveFileName, "42", "2"), "M") txtGOLD.Text = HexToDecOrAscii(GetFileData(SaveFileName, "46", "2"), "M") txtITEM(0).Text = HexToDecOrAscii(GetFileData(SaveFileName, "82", "1"), "S") txtITEM(1).Text = HexToDecOrAscii(GetFileData(SaveFileName, "97", "1"), "S") txtITEM(2).Text = HexToDecOrAscii(GetFileData(SaveFileName, "AC", "1"), "S") txtITEM(3).Text = HexToDecOrAscii(GetFileData(SaveFileName, "C1", "1"), "S") txtITEM(4).Text = HexToDecOrAscii(GetFileData(SaveFileName, "D6", "1"), "S") End Sub |
cmdRead_Click プロシージャ3
'持っていないアイテムの個数を増やすのを避けるための処理 ItemNumber = 0 For i = 0 To 4 If txtITEM(i).Text <> "0" Then txtITEM(i).Enabled = True ItemNumber = ItemNumber + 1 Else txtITEM(i).Text = "" End If Next i End Sub |
データ入力チェック処理 |
---|
txtHP_GotFocus プロシージャ
Private Sub txtHP_GotFocus() SelText txtHP End Sub txtHP_LostFocus プロシージャ Private Sub txtHP_LostFocus() If txtHP.Text = "" Then Exit Sub End If If IsNumeric(txtHP.Text) = False Then MsgBox "数値以外は入力できません", vbOKOnly + vbExclamation, "入力エラー" txtHP.SetFocus Exit Sub End If If CLng(txtHP.Text) < 1 Or CLng(txtHP.Text) > 999 Then MsgBox "入力できる範囲をは、1 〜 999 までです", vbOKOnly + vbExclamation, "入力エラー" txtHP.SetFocus Exit Sub End If End Sub |
セーブデータ書き込み処理 |
---|
cmdWrite_Click プロシージャ
Private Sub cmdWrite_Click() If InputDataCheck <> 0 Then Exit Sub Dataset cmdEnd.SetFocus End Sub |
InputDataCheck プロシージャ
Private Function InputDataCheck() As Long InputDataCheck = 1 If Len(txtHP.Text) = 0 Then MsgBox "HPの値を入力して下さい", vbOKOnly + vbExclamation, "空値エラー" txtHP.SetFocus Exit Function End If If Len(txtMaxHP.Text) = 0 Then MsgBox "最大HPの値を入力して下さい", vbOKOnly + vbExclamation, "空値エラー" txtMaxHP.SetFocus Exit Function End If If Len(txtSTR.Text) = 0 Then MsgBox "STRの値を入力して下さい", vbOKOnly + vbExclamation, "空値エラー" txtSTR.SetFocus Exit Function End If If Len(txtDEF.Text) = 0 Then MsgBox "DEFの値を入力して下さい", vbOKOnly + vbExclamation, "空値エラー" txtDEF.SetFocus Exit Function End If If Len(txtLUCK.Text) = 0 Then MsgBox "LUCKの値を入力して下さい", vbOKOnly + vbExclamation, "空値エラー" txtLUCK.SetFocus Exit Function End If If Len(txtSPEED.Text) = 0 Then MsgBox "SPEEDの値を入力して下さい", vbOKOnly + vbExclamation, "空値エラー" txtSPEED.SetFocus Exit Function End If If Len(txtGOLD.Text) = 0 Then MsgBox "GOLDの値を入力して下さい", vbOKOnly + vbExclamation, "空値エラー" txtGOLD.SetFocus Exit Function End If For i = 0 To 4 If ItemNumber > i And txtITEM(i).Text = "" Then MsgBox "アイテムの数を入力して下さい", vbOKOnly + vbExclamation, "空値エラー" txtITEM(i).SetFocus Exit Function End If Next i If txtHP.Text > txtMaxHP.Text Then MsgBox "HPに、MaxHPより大きい値が指定されています", vbOKOnly + vbExclamation, "範囲エラー" txtHP.SetFocus Exit Function End If InputDataCheck = 0 End Function |
Dataset プロシージャ
Private Sub Dataset() Const MAX_CODE = 12 Dim Code(MAX_CODE - 1) As String '改造コードを格納する配列 Code(0) = "30-M" & txtHP.Text Code(1) = "32-M" & txtMaxHP.Text Code(2) = "38-M" & txtSTR.Text Code(3) = "3C-M" & txtDEF.Text Code(4) = "40-M" & txtLUCK.Text Code(5) = "42-M" & txtSPEED.Text Code(6) = "46-M" & txtGOLD.Text '持っていないアイテムの個数を増やすのを避けるための処理 If ItemNumber > 4 Then Code(11) = "D6-S" & txtITEM(4).Text End If If ItemNumber > 3 Then Code(10) = "C1-S" & txtITEM(3).Text End If If ItemNumber > 2 Then Code(9) = "AC-S" & txtITEM(2).Text End If If ItemNumber > 1 Then Code(8) = "97-S" & txtITEM(1).Text End If If ItemNumber > 0 Then Code(7) = "82-S" & txtITEM(0).Text End If Dim ret As Long For i = 0 To UBound(Code) - (5 - ItemNumber) ret = BinFileEdit(SaveFileName, Code(i)) If ret <> 0 Then MsgBox "エラーです" & vbCrLf & "エラー番号 " & ret End If Next i MsgBox "セーブデータを書き換えました", vbOKOnly, "書き換え完了" End Sub |