Jump to content
Sign in to follow this  
CyberSaint

Programming in Visual Basic | For Those Who Have Errors

Recommended Posts

This is a tutorial for those who keep getting errors. Don't worry, we have all been there.

 

I will simply give you a template that you can use to create your programs. 

 

 

 

Imports PackageIO



Public Class Form1
 
Dim Filepath As String



Private Sub ButtonItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem3.Click

Dim Open As New OpenFileDialog

Open.Filter = "Gamesave (*.*)|*.*"

Open.Title = "Open Gamesave"

If Open.ShowDialog = Windows.Forms.DialogResult.OK Then

Filepath = Open.FileName

Else

Return

End If

End Sub
 
(This Code Will Allow You To Open The Save)

----------------------------------------------------------------------------------------------------------

Private Sub ButtonItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem4.Click

Try

WriteFile()

MsgBox(("File Saved!"))

ReadFile()

Catch ex As Exception

MsgBox("Error", MsgBoxStyle.Critical, "")

End Try

End Sub
 
(This Code Will Allow You To Save The File)

----------------------------------------------------------------------------------------------------------

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Public Sub ReadFile()

Dim Reader As New PackageIO.Reader(Filepath, PackageIO.Endian.Big)

Reader.Position = "Hex Value" (Without Quotes)
NumericUpDown1.Value = Reader.ReadInt32

Reader.Position = "Hex Value" (Without Quotes)
NumericUpDown2.Value = Reader.ReadInt32

Reader.Close()

End Sub
 
(This Code Will Tell The Program To Read The Current Values Of The Original Save "Does Not Always Work, But Don't Worry, Not a Big Issue")
---------------------------------------------------------------------------------------------------------

Public Sub WriteFile()

Dim Writer As New PackageIO.Writer(Filepath, PackageIO.Endian.Big)

Writer.Position = "Hex Value" (Without Quotes)
Writer.WriteInt32(NumericUpDown3.Value)

Writer.Position = "Hex Value" (Without Quotes)
Writer.WriteInt32(NumericUpDown4.Value)

Writer.Close()

End Sub

End Class
 
(This Final Code Will Tell The Program To Overwrite The Values Of The Original Save)

 

Have Fun Programming! If you have any errors, please feel free to contact me. ;)

Share this post


Link to post
Share on other sites

I never get errors, just syntax.

Share this post


Link to post
Share on other sites

I never get errors, just syntax.

Umm ok, well this tutorial is for those who get errors.

Share this post


Link to post
Share on other sites

Umm ok, well this tutorial is for those who get errors.

Whine about it?

Share this post


Link to post
Share on other sites

Whine about it?

 

Whine about what? 

Share this post


Link to post
Share on other sites

Whine about what? 

:facepalm: Nevermind

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×