Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- vb.net cheats :
- walkthrough in the description
- name of game : feZet v1
- created by : moti barski
- [IMG]http://img163.imageshack.us/img163/8595/unledjho.png[/IMG]
- http://imageshack.us/photo/my-images/163/unledjho.png/
- name of game : feZet v1
- compiler (programming platform) : vb.net express edition 2010
- created by : moti barski ( which also made the yotamarker A.I)
- this is a 2 player programmable 2 player versus game
- 13 character vs game, each char has dif magic.
- wins counter
- after 2 battles p2 do an action or move if game jams up
- controls :
- p1 :
- a <-, s->, t hit, g grab, y shield, u charge magic, j magic
- p2 :
- left arrow <-, right arrow ->, insert hit, Delete grab,Home shield, Page Up charge magic, Page Down magic
- up to select character
- install walkthrough :
- in c:\ make a fezet named folder
- add files : 1.bmp - 13.bmp (characters images
- add files : magicp1.bmp, magicp2.bmp ' magic displayed arena for char 1 or 2
- if only using the .exe file of the game .net 3.5 framework or above should be installed
- Public Class Form1 ' this is the feZet : a 2 player versus game written by Moti Barski
- ' programmacaly addables to this game :
- ' joystick, fatality,digivolution,sounds, story mode, game genres, online play
- ' codes enabling the above features can be found in the free to download book battle programming
- ' form control list : picturebox 1,2 size : 106,146
- Dim magic1, magic2 As Bitmap ' images displayed after magic in respect of character
- Dim char1Selected As Boolean = False
- Dim ar(0 To 12) As Bitmap ' character array
- Dim char1, char2, p1ATK, p2ATK, p1Magicfill, p2magicfill As Integer
- Dim p1X As Integer = 1 ' position of char 1
- Dim p1JumpForeward As Integer = 10 'can be calibrated
- Dim p1JumpBackward As Integer = 5
- Dim p2X As Integer = p1X + 900
- Dim p2JumpForeward As Integer = 10
- Dim p2JumpBackward As Integer = 5
- Dim direction As Char = "N" ' N = no direction taken not left not right m'k
- Dim direction2 As Char = "N"
- Dim Action As Byte = 0 ' 0 nothing,1-hit,2-grab,3-magic fill,4magic, 5 shield
- Dim Action2 As Byte = 0
- Dim charSpace As Integer = 50 ' minimum space betwin the 2 chars when close
- Dim p1Wins As Integer = 0
- Dim p2Wins As Integer = 0
- Dim boolchar1 As Boolean = True ' if true char 1 will work magic
- Function charsWereSelected(ByVal pNum As Byte) As String
- 'set character name after selection
- Dim charName As String = ""
- Select Case pNum
- Case 1
- charName = "moti barski"
- Case 2
- charName = "Lord_Rat"
- Case 3
- charName = "kregg"
- Case 4
- charName = "FunkyDexter"
- Case 5
- charName = "baja yu"
- Case 6
- charName = "Milk"
- Case 7
- charName = "Pc_Not_Mac"
- Case 8
- charName = "namrekka"
- Case 9
- charName = "Shaggy Hiker"
- Case 10
- charName = "stlaural"
- Case 11
- charName = "zaza"
- Case 12
- charName = "nissan cohen"
- Case 13
- charName = "Jenner"
- Case Else
- End Select
- Return charName
- End Function
- Sub gotHit(ByVal player As Byte) ' player 1 or 2 goes to it's respective side and hp is reduced unless he has sp magic
- If player = 2 Then
- p2X = 901
- PictureBox2.Location = New Point(p2X, PictureBox2.Location.Y)
- ' lower p2 hp by p1 ATK
- Dim Temp1 As Byte
- Temp1 = ProgressBar4.Value
- If Temp1 - p1ATK >= 0 Then
- ProgressBar4.Value -= p1ATK
- Else
- ProgressBar4.Value = 0
- End If
- Else
- p1X = 1
- PictureBox1.Location = New Point(p1X, PictureBox1.Location.Y)
- ' lower p1 hp by p2 ATK
- Dim Temp1 As Byte
- Temp1 = ProgressBar3.Value
- If Temp1 - p2ATK >= 0 Then
- ProgressBar3.Value -= p2ATK
- Else
- ProgressBar3.Value = 0
- End If
- End If
- End Sub
- Sub magic(ByVal player As Integer)
- Dim char3 As Integer = 0 ' anti glitch for char 3
- Dim regionalBool As Boolean = False ' anti glitch for char 2
- If player = 1 Then
- If ProgressBar1.Value = ProgressBar1.Maximum Then
- Select Case char1
- Case 1 ' teleport hadoken
- If boolchar1 Then
- If Action2 <> 5 Then
- If ProgressBar4.Value - 50 < 0 Then
- ProgressBar4.Value = 0
- Else
- ProgressBar4.Value -= 50
- End If
- Else ' if not needed
- If ProgressBar3.Value - 10 < 0 Then
- ProgressBar3.Value = 0
- Else
- ProgressBar3.Value -= 10
- End If
- End If
- End If
- boolchar1 = Not boolchar1
- Case 2 ' eat magic
- ProgressBar1.Value = 90
- ProgressBar2.Value = 0
- regionalBool = True
- Case 3 'replace char
- Dim tb As Bitmap
- tb = PictureBox1.Image
- PictureBox1.Image = PictureBox2.Image
- PictureBox2.Image = tb
- Dim tHp As Integer
- tHp = ProgressBar3.Value
- ProgressBar3.Value = ProgressBar4.Value
- ProgressBar4.Value = tHp
- ' replace magicbar maximum
- tHp = ProgressBar1.Maximum
- ProgressBar1.Maximum = ProgressBar2.Maximum
- ProgressBar2.Maximum = tHp
- char3 = ProgressBar2.Value
- ProgressBar2.Value = 0
- tHp = p1ATK ' replace ATK
- p1ATK = p2ATK
- p2ATK = tHp
- tHp = p1JumpForeward 'replace speed
- p1JumpForeward = p2JumpForeward
- p2JumpForeward = tHp
- tHp = char1 ' replace char
- char1 = char2
- char2 = tHp
- Case 4
- If ProgressBar3.Value < 31 Then
- ProgressBar4.Value = 30
- End If
- Case 5 ' hard to defeat near end of battle
- ProgressBar3.Value = 15
- Case 6 ' heal (milk drink)
- Dim tx As Integer
- tx = ProgressBar3.Value
- If tx + 5 > 100 Then
- tx = 100
- End If
- ProgressBar3.Value = tx + 5
- Case 7
- If ProgressBar4.Value - 10 < 0 Then
- ProgressBar4.Value = 0
- Else
- ProgressBar4.Value -= 10
- End If
- Case 8 'death note
- ProgressBar4.Value = 0
- Case 9 ' reversable invisibility (lurk)
- PictureBox1.Visible = Not PictureBox1.Visible
- Case 10 ' death rollet
- If Second(Now) Mod 2 = 1 Then
- ProgressBar3.Value = 0
- Else
- ProgressBar4.Value = 0
- End If
- Case 11
- If ProgressBar4.Value > 90 Then
- ProgressBar3.Value = 100
- End If
- Case 12
- p1ATK += 1
- Case 13
- ProgressBar3.Value = 1
- ProgressBar4.Value = 1
- End Select
- Me.BackgroundImage = magic1
- If Not regionalBool Then
- ProgressBar1.Value = char3 ' or 0 (char3 is special case)
- End If
- End If
- Else ' player 2
- If ProgressBar2.Value = ProgressBar2.Maximum Then
- Select Case char2
- Case 1
- If boolchar1 Then
- If Action2 <> 5 Then
- If ProgressBar3.Value - 50 < 0 Then
- ProgressBar3.Value = 0
- Else
- ProgressBar3.Value -= 50
- End If
- Else
- If ProgressBar4.Value - 10 < 0 Then
- ProgressBar4.Value = 0
- Else
- ProgressBar4.Value -= 10
- End If
- End If
- End If
- boolchar1 = Not boolchar1
- Case 2 ' eat magic
- ProgressBar1.Value = 90
- ProgressBar2.Value = 0
- regionalBool = True
- Case 3 'replace char
- Dim tb As Bitmap
- tb = PictureBox1.Image
- PictureBox1.Image = PictureBox2.Image
- PictureBox2.Image = tb
- Dim tHp As Integer
- tHp = ProgressBar3.Value
- ProgressBar3.Value = ProgressBar4.Value
- ProgressBar4.Value = tHp
- ' replace magicbar maximum
- tHp = ProgressBar1.Maximum
- ProgressBar1.Maximum = ProgressBar2.Maximum
- ProgressBar2.Maximum = tHp
- char3 = ProgressBar1.Value
- ProgressBar1.Value = 0
- tHp = p1ATK ' replace ATK
- p1ATK = p2ATK
- p2ATK = tHp
- tHp = p1JumpForeward 'replace speed
- p1JumpForeward = p2JumpForeward
- p2JumpForeward = tHp
- tHp = char1 ' replace char
- char1 = char2
- char2 = tHp
- Case 4
- If ProgressBar4.Value < 31 Then
- ProgressBar3.Value = 30
- End If
- Case 5
- ProgressBar4.Value = 15
- Case 6
- Dim tx As Integer
- tx = ProgressBar4.Value
- If tx + 5 > 100 Then
- tx = 100
- End If
- ProgressBar4.Value = tx + 5
- Case 7
- If ProgressBar3.Value - 10 < 0 Then
- ProgressBar3.Value = 0
- Else
- ProgressBar3.Value -= 10
- End If
- Case 8 'death note
- ProgressBar3.Value = 0
- Case 9 ' reversable
- PictureBox2.Visible = Not PictureBox2.Visible
- Case 10
- If Second(Now) Mod 2 = 1 Then
- ProgressBar3.Value = 0
- Else
- ProgressBar4.Value = 0
- End If
- Case 11
- If ProgressBar3.Value > 90 Then
- ProgressBar4.Value = 100
- End If
- Case 12
- p2ATK += 1
- Case 13
- ProgressBar3.Value = 1
- ProgressBar4.Value = 1
- End Select
- Me.BackgroundImage = magic2
- If Not regionalBool Then
- ProgressBar2.Value = char3 ' or 0 char3 is special case
- End If
- End If
- End If
- End Sub
- Sub isBattleOver() ' if so variables are reset
- If ProgressBar3.Value = 0 Then
- Label5.Visible = True
- Timer1.Enabled = False
- PictureBox2.Location = New Point(901, PictureBox2.Location.Y)
- PictureBox1.Location = New Point(1, PictureBox1.Location.Y)
- boolchar1 = True
- PictureBox1.Visible = True
- PictureBox2.Visible = True
- TextBox1.Text = "1"
- p1JumpForeward = 10
- p2JumpForeward = 10
- p1ATK = 5
- p2ATK = 5
- Me.BackgroundImage = Nothing
- If ProgressBar4.Value = 0 Then
- Label5.Text = "draw"
- p1Wins += 1
- p2Wins += 1
- Label3.Text = p1Wins & " " & "WINS"
- Label4.Text = p2Wins & " " & "WINS"
- ElseIf ProgressBar4.Value = 100 Then
- Label5.Text = "player 2 wins flawless victory"
- p2Wins += 1
- Label4.Text = p2Wins & " " & "WINS"
- Else
- Label5.Text = "player 2 wins"
- p2Wins += 1
- Label4.Text = p2Wins & " " & "WINS"
- End If
- ElseIf ProgressBar4.Value = 0 Then
- Label5.Visible = True
- Timer1.Enabled = False
- PictureBox2.Location = New Point(901, PictureBox2.Location.Y)
- PictureBox1.Location = New Point(1, PictureBox1.Location.Y)
- TextBox1.Text = "1"
- boolchar1 = True
- p1JumpForeward = 10
- p2JumpForeward = 10
- Me.BackgroundImage = Nothing
- If ProgressBar3.Value = 0 Then
- Label5.Text = "draw"
- p1Wins += 1
- p2Wins += 1
- Label3.Text = p1Wins & " " & "WINS"
- Label4.Text = p2Wins & " " & "WINS"
- ElseIf ProgressBar3.Value = 100 Then
- Label5.Text = "player 1 wins flawless victory"
- p1Wins += 1
- Label3.Text = p1Wins & " " & "WINS"
- Else
- Label5.Text = "player 1 WINS"
- p1Wins += 1
- Label3.Text = p1Wins & " " & "WINS"
- End If
- End If
- End Sub
- Private Sub TextBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
- ' get input
- Try
- If Not Timer1.Enabled And Not char1Selected Then
- If e.KeyCode = Keys.Right Then
- If Not TextBox1.Text = 1 Then
- TextBox1.Text -= 1
- PictureBox1.Image = ar(TextBox1.Text - 1)
- Label1.Text = charsWereSelected(TextBox1.Text)
- End If
- ElseIf e.KeyCode = Keys.Left And Not TextBox1.Text > 12 Then
- TextBox1.Text += 1
- PictureBox1.Image = ar(TextBox1.Text - 1)
- Label1.Text = charsWereSelected(TextBox1.Text)
- ElseIf e.KeyCode = Keys.Up Then
- char1Selected = True
- char1 = TextBox1.Text
- 'special char
- If char1 = 12 Then
- p1JumpForeward = 15
- ElseIf char1 = 8 Then
- ProgressBar1.Maximum = 300
- End If
- 'end of special char
- TextBox1.Text = 1
- p1ATK = 5
- End If
- ElseIf Not Timer1.Enabled And char1Selected Then
- If e.KeyCode = Keys.Right Then
- If Not TextBox1.Text = 1 Then
- TextBox1.Text -= 1
- PictureBox2.Image = ar(TextBox1.Text - 1)
- Label2.Text = charsWereSelected(TextBox1.Text)
- End If
- ElseIf e.KeyCode = Keys.Left And Not TextBox1.Text > 12 Then
- TextBox1.Text += 1
- PictureBox2.Image = ar(TextBox1.Text - 1)
- Label2.Text = charsWereSelected(TextBox1.Text)
- ElseIf e.KeyCode = Keys.Up And char1 <> TextBox1.Text Then
- char1Selected = False
- char2 = TextBox1.Text
- 'special at char select char
- If char2 = 12 Then
- p2JumpForeward = 15
- ElseIf char2 = 8 Then
- ProgressBar2.Maximum = 300
- End If
- 'end of special char
- TextBox1.Text = ""
- Action = 0
- Action2 = 0
- direction = "N"
- direction2 = "N"
- p2ATK = 5
- Label5.Visible = False
- ProgressBar3.Value = 100
- ProgressBar4.Value = 100
- ProgressBar2.Value = 0
- ProgressBar1.Value = 0
- Timer1.Enabled = True
- End If
- End If
- Catch ex As Exception
- TextBox1.Text = "1"
- End Try
- ' player1
- If e.KeyCode = Keys.S Then
- direction = "R"
- ElseIf e.KeyCode = Keys.A Then
- direction = "L"
- ElseIf e.KeyCode = Keys.T Then
- Action = 1
- ElseIf e.KeyCode = Keys.G Then
- Action = 2
- ElseIf e.KeyCode = Keys.U Then
- Action = 3
- ElseIf e.KeyCode = Keys.J Then
- Action = 4
- ElseIf e.KeyCode = Keys.Y Then
- Action = 5
- End If
- 'player2
- If e.KeyCode = Keys.Right Then
- direction2 = "R"
- ElseIf e.KeyCode = Keys.Left Then
- direction2 = "L"
- ElseIf e.KeyCode = Keys.Insert Then
- Action2 = 1
- ElseIf e.KeyCode = Keys.Delete Then
- Action2 = 2
- ElseIf e.KeyCode = Keys.PageUp Then
- Action2 = 3
- ElseIf e.KeyCode = Keys.PageDown Then
- Action2 = 4
- ElseIf e.KeyCode = Keys.Home Then
- Action2 = 5 ' * defend
- End If
- End Sub
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- ' initialize variables at form load event
- Dim fs1 As IO.FileStream = New IO.FileStream("c:\fezet\" & "magicp1.bmp", IO.FileMode.Open)
- magic1 = Image.FromStream(fs1)
- Dim fs2 As IO.FileStream = New IO.FileStream("c:\fezet\" & "magicp2.bmp", IO.FileMode.Open)
- magic2 = Image.FromStream(fs2)
- Label5.Visible = False
- Label3.Text = "0 win"
- Label4.Text = "0 win"
- Label1.Text = "moti barski"
- Label2.Text = "moti barski"
- ProgressBar3.Value = 100
- ProgressBar4.Value = 100
- TextBox1.Text = 1
- For index = 1 To 13
- Dim fs As IO.FileStream = New IO.FileStream("c:\fezet\" & TextBox1.Text & ".bmp", IO.FileMode.Open)
- ar(index - 1) = Image.FromStream(fs)
- fs.Close()
- TextBox1.Text += 1
- Next
- TextBox1.Text = 1
- Me.Width = 1000
- PictureBox2.Location = New Point(1000 - PictureBox2.Width, PictureBox2.Location.Y)
- PictureBox1.Location = New Point(1, PictureBox1.Location.Y)
- End Sub
- Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
- ' the battle is here
- Dim areClose As Boolean = False 'combo how to
- Dim areCloseEnougth As Boolean = False
- If direction = "R" Then
- If p1X + p1JumpForeward + charSpace < p2X Then 'p1jump + space of chars as var
- p1X += p1JumpForeward
- PictureBox1.Location = New Point(p1X, PictureBox1.Location.Y)
- Else
- areClose = True
- End If
- ElseIf direction = "L" Then
- If p1X - p1JumpBackward > 1 Then
- p1X -= p1JumpBackward
- PictureBox1.Location = New Point(p1X, PictureBox1.Location.Y)
- End If
- End If
- If direction2 = "L" Then
- If p2X - p2JumpForeward - charSpace > p1X Then
- p2X -= p2JumpForeward
- PictureBox2.Location = New Point(p2X, PictureBox2.Location.Y)
- Else
- areClose = True
- End If
- ElseIf direction2 = "R" Then
- If p2X + p2JumpBackward < 900 Then
- p2X += p2JumpBackward
- PictureBox2.Location = New Point(p2X, PictureBox2.Location.Y)
- End If
- End If
- If p1X + p1JumpForeward + charSpace >= p2X Then
- areCloseEnougth = True
- End If
- '0 nothing,1-hit,2-grab,3-magic fill,4magic
- If areCloseEnougth Then ' use areclose boolean for move close + move
- If Action = 1 Then 'p1 hit
- If Action2 = 0 Or Action2 = 2 Or Action2 = 3 Or Action2 = 4 Then
- ' spin p1, lower p2 hp p2 pos to back
- Dim bm As Bitmap = PictureBox1.Image
- bm.RotateFlip(RotateFlipType.Rotate180FlipX)
- PictureBox1.Image = bm
- gotHit(2)
- ElseIf Action2 = 5 Then
- ' stop hit p1
- Action = 0
- ElseIf Action2 = 1 Then
- 'spin hit p1,p2 pos p1,p2 to back
- Dim bm As Bitmap = PictureBox1.Image
- bm.RotateFlip(RotateFlipType.Rotate180FlipX)
- PictureBox1.Image = bm
- bm = PictureBox2.Image
- bm.RotateFlip(RotateFlipType.Rotate180FlipX)
- PictureBox2.Image = bm
- gotHit(2)
- gotHit(1)
- End If
- ElseIf Action = 5 Then
- If Action2 = 1 Then
- Action2 = 0
- ElseIf Action2 = 2 Then
- ' pos p1 back,lower p1 hp, spin grab p2
- gotHit(1)
- Dim bm As Bitmap = PictureBox2.Image
- bm.RotateFlip(RotateFlipType.Rotate90FlipY)
- PictureBox2.Image = bm
- ElseIf Action2 = 3 Then
- 'p2 magic fill
- If ProgressBar2.Value < ProgressBar2.Maximum Then
- ProgressBar2.Value += 1
- End If
- ElseIf Action2 = 4 Then
- 'magic p2
- magic(2)
- End If
- ElseIf Action = 2 Then
- If Action2 = 1 Then
- 'p1 lower hp, p1 go to back, p2hit spin
- Dim bm As Bitmap = PictureBox2.Image
- bm.RotateFlip(RotateFlipType.Rotate180FlipX)
- PictureBox2.Image = bm
- gotHit(1)
- ElseIf Action2 = 0 Or Action2 = 3 Or Action2 = 4 Or Action2 = 5 Then
- 'p1 grab spin, p2 lower hp,p2 go back
- Dim bm As Bitmap = PictureBox1.Image
- bm.RotateFlip(RotateFlipType.Rotate90FlipY)
- PictureBox1.Image = bm
- gotHit(2)
- ElseIf Action2 = 2 Then
- 'p1 p2 lower hp and go back and grab spin
- Dim bm As Bitmap = PictureBox1.Image
- bm.RotateFlip(RotateFlipType.Rotate90FlipY)
- PictureBox1.Image = bm
- bm = PictureBox2.Image
- bm.RotateFlip(RotateFlipType.Rotate90FlipY)
- PictureBox2.Image = bm
- gotHit(1)
- gotHit(2)
- End If
- ElseIf Action = 0 Then
- If Action2 = 1 Then
- 'p2 hit spin ,p1 lower hp go back
- Dim bm As Bitmap = PictureBox2.Image
- bm.RotateFlip(RotateFlipType.Rotate180FlipX)
- PictureBox2.Image = bm
- gotHit(1)
- ElseIf Action2 = 2 Then
- 'p2 grab spin ,p1 lower hp go back
- Dim bm As Bitmap = PictureBox2.Image
- bm.RotateFlip(RotateFlipType.Rotate90FlipY)
- PictureBox2.Image = bm
- gotHit(1)
- ElseIf Action2 = 3 Then
- 'p2 magic fill
- If ProgressBar2.Value < ProgressBar2.Maximum Then
- ProgressBar2.Value += 1
- End If
- ElseIf Action2 = 4 Then
- 'p2 magic
- magic(2)
- End If
- ElseIf Action = 3 Then
- If Action2 = 4 Then
- 'p2 magic
- magic(2)
- ElseIf Action2 = 2 Then
- 'p2 grab spin,p1 lower hp go back
- Dim bm As Bitmap = PictureBox2.Image
- bm.RotateFlip(RotateFlipType.Rotate90FlipY)
- PictureBox2.Image = bm
- gotHit(1)
- ElseIf Action2 = 1 Then
- 'p2 hit spin, p1 lower hp, go back
- Dim bm As Bitmap = PictureBox2.Image
- bm.RotateFlip(RotateFlipType.Rotate180FlipX)
- PictureBox2.Image = bm
- gotHit(1)
- ElseIf Action2 = 5 Then
- 'magic fill p1
- If ProgressBar1.Value < ProgressBar1.Maximum Then
- ProgressBar1.Value += 1
- End If
- ElseIf Action2 = 0 Then
- 'magic fill p1
- If ProgressBar1.Value < ProgressBar1.Maximum Then
- ProgressBar1.Value += 1
- End If
- ElseIf Action2 = 3 Then
- 'p1,p2 magic fill
- magic(1)
- magic(2)
- If ProgressBar1.Value < ProgressBar1.Maximum Then
- ProgressBar1.Value += 1
- End If
- If ProgressBar2.Value < ProgressBar2.Maximum Then
- ProgressBar2.Value += 1
- End If
- End If
- ElseIf Action = 4 Then
- If Action2 = 3 Then
- 'p1 magic
- magic(1)
- ElseIf Action2 = 1 Then
- 'p1 go back lower health,p2 hit spin
- Dim bm As Bitmap = PictureBox2.Image
- bm.RotateFlip(RotateFlipType.Rotate180FlipX)
- PictureBox2.Image = bm
- gotHit(1)
- ElseIf Action2 = 0 Or Action2 = 5 Then
- 'p1 magic
- magic(1)
- ElseIf Action2 = 2 Then
- 'p2 grab spin, p1 lower hp go back
- Dim bm As Bitmap = PictureBox2.Image
- bm.RotateFlip(RotateFlipType.Rotate90FlipY)
- PictureBox2.Image = bm
- gotHit(1)
- End If
- End If
- ElseIf Action = 1 Then
- 'p1 hit spin
- Dim bm As Bitmap = PictureBox1.Image
- bm.RotateFlip(RotateFlipType.Rotate180FlipX)
- PictureBox1.Image = bm
- ElseIf Action = 2 Then
- 'p1 grab spin
- Dim bm As Bitmap = PictureBox1.Image
- bm.RotateFlip(RotateFlipType.Rotate90FlipY)
- PictureBox1.Image = bm
- ElseIf Action = 3 Then
- 'p1 magic fill
- If ProgressBar1.Value < ProgressBar1.Maximum Then
- ProgressBar1.Value += 1
- End If
- ElseIf Action = 4 Then
- 'p1 magic
- magic(1)
- End If
- If Not areClose Then
- If Action2 = 1 Then
- 'p2 hit spin
- Dim bm As Bitmap = PictureBox2.Image
- bm.RotateFlip(RotateFlipType.Rotate180FlipX)
- PictureBox2.Image = bm
- ElseIf Action2 = 2 Then
- 'p2 grab spin
- Dim bm As Bitmap = PictureBox2.Image
- bm.RotateFlip(RotateFlipType.Rotate90FlipY)
- PictureBox2.Image = bm
- ElseIf Action2 = 3 Then
- 'p2 magic fill
- If ProgressBar2.Value < ProgressBar2.Maximum Then
- ProgressBar2.Value += 1
- End If
- ElseIf Action2 = 4 Then
- 'p2 magic
- magic(2)
- End If
- End If
- TextBox1.Text = "" '* from hya
- 'is battle over count p1 p2 :win, draw (both) or flawless victory or p1,2 win stop timer reset textbox to 1, image1
- isBattleOver()
- End Sub
- Private Sub TextBox1_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp
- ' enable p1 and p2 simoltanious input
- If e.KeyCode = Keys.S Or e.KeyCode = Keys.A Then
- direction = "N"
- ElseIf e.KeyCode = Keys.T Or e.KeyCode = Keys.G Or e.KeyCode = Keys.U Or e.KeyCode = Keys.J Or e.KeyCode = Keys.Y Then
- Action = 0
- End If
- If e.KeyCode = Keys.Right Or e.KeyCode = Keys.Left Then
- direction2 = "N"
- ElseIf e.KeyCode = Keys.Insert Or e.KeyCode = Keys.Delete Or e.KeyCode = Keys.Home Or e.KeyCode = Keys.PageUp Or e.KeyCode = Keys.PageDown Then
- Action2 = 0
- End If
- End Sub 'exit btn
- End Class
- TCP CHAT
- client :
- '5 textboxes txtIP, txtPort, txtUsername, txtMain, txtSend
- 'btnconnect,btnsend,btndisconnect
- Public Class frmMainClient
- Private client As System.Net.Sockets.TcpClient
- Private Const BYTES_TO_READ As Integer = 255
- Private readBuffer(BYTES_TO_READ) As Byte
- Private Delegate Sub WriteText(ByVal text As String)
- Private Sub BtnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnConnect.Click
- If txtIP.Text = "" Or txtPort.Text = "" Or txtUserName.Text = "" Or IsNumeric(txtPort.Text) = False Or txtUserName.Text.IndexOf("|") >= 0 Then MsgBox("Fill text boxes properly") : Exit Sub
- client = New System.Net.Sockets.TcpClient(txtIP.Text, txtPort.Text)
- client.GetStream.BeginRead(readBuffer, 0, BYTES_TO_READ, AddressOf DoRead, Nothing)
- SendMessage("/CONNECT|" & txtUserName.Text)
- txtUserName.Enabled = False
- BtnSend.Enabled = True
- BtnConnect.Enabled = False
- txtSend.Enabled = True
- txtIP.Enabled = False
- txtPort.Enabled = False
- End Sub
- Private Sub DoRead(ByVal ar As System.IAsyncResult)
- Dim totalRead As Integer
- Try
- totalRead = client.GetStream.EndRead(ar) 'Ends the reading and returns the number of bytes read.
- Catch ex As Exception
- 'The underlying socket have probably been closed OR an error has occured whilst trying to access it, either way, this is where you should remove close all eventuall connections 'to this client and remove it from the list of connected clients.
- End Try
- If totalRead > 0 Then
- 'the readBuffer array will contain everything read from the client
- Dim receivedString As String = System.Text.Encoding.UTF8.GetString(readBuffer, 0, totalRead)
- MessageReceived(receivedString)
- End If
- Try
- client.GetStream.BeginRead(readBuffer, 0, BYTES_TO_READ, AddressOf DoRead, Nothing) 'Begin the reading again.
- Catch ex As Exception
- 'The underlying socket have probably been closed OR an error has occured whilst trying to access it, either way, this is where you should remove close all eventuall connections 'to this client and remove it from the list of connected clients.
- End Try
- End Sub
- Private Sub MessageReceived(ByVal message As String)
- Select Case message
- Case "/Connected"
- ConnectionStatus("Client : Connected")
- Case Else
- WriteToMainText(message & vbCrLf)
- End Select
- End Sub
- Private Sub ConnectionStatus(ByVal Message As String)
- If Me.InvokeRequired Then
- Me.Invoke(New WriteText(AddressOf ConnectionStatus), Message)
- Else
- Me.Text = "Client : Connected"
- BtnDisconnect.Visible = True
- BtnConnect.Height = 36
- BtnConnect.Top = 9
- End If
- End Sub
- Private Sub WriteToMainText(ByVal Message As String)
- If txtMain.InvokeRequired Then
- Me.Invoke(New WriteText(AddressOf WriteToMainText), Message)
- Else
- txtMain.AppendText(Message)
- txtMain.SelectionStart = txtMain.Text.Length
- End If
- End Sub
- Private Sub SendMessage(ByVal Msg As String)
- Dim sw As IO.StreamWriter
- Try
- sw = New IO.StreamWriter(client.GetStream)
- sw.Write(Msg)
- sw.Flush()
- Catch ex As Exception
- MessageBox.Show(ex.ToString)
- End Try
- End Sub
- Private Sub frmMainClient_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- BtnDisconnect.Visible = False
- txtMain.ReadOnly = True
- BtnSend.Enabled = False
- txtSend.Enabled = False
- End Sub
- Private Sub BtnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSend.Click
- SendMessage(txtUserName.Text & ": " & txtSend.Text)
- WriteToMainText(txtUserName.Text & ": " & txtSend.Text & vbCrLf)
- txtSend.Text = ""
- End Sub
- Private Sub BtnDisconnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnDisconnect.Click
- SendMessage("/DISCONNECT|" & txtUserName.Text)
- BtnConnect.Enabled = True
- BtnDisconnect.Visible = False
- txtUserName.Enabled = True
- BtnSend.Enabled = False
- txtSend.Enabled = False
- txtIP.Enabled = True
- txtPort.Enabled = True
- Me.Text = "Client"
- End Sub
- Private Sub txtSend_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtSend.Enter
- Me.AcceptButton = BtnSend
- End Sub
- End Class
- server :
- 'We have
- '4 textboxes txtSend, txtUsername, txtPort, txtMain (txtMain is multiline and readonly)
- 'lblConnection
- 'btnListen, btnSend, btnSendAll
- 'listbox lbClients
- Public Class frmMainServer
- Private listener As System.Net.Sockets.TcpListener
- Private listenThread As System.Threading.Thread
- Private clients As New List(Of ConnectedClient) 'This list will store all connected clients.
- Private Delegate Sub StringDelegate(ByVal text As String)
- Private Sub frmMainServer_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- 'lblRemoveClient.Visible = False
- txtMain.ReadOnly = True
- txtSend.Enabled = False
- BtnSend.Enabled = False
- btnSendAll.Enabled = False
- End Sub
- Private Sub DoListen()
- Dim incomingClient As System.Net.Sockets.TcpClient
- Do
- incomingClient = listener.AcceptTcpClient 'Accept the incoming connection. This is a blocking method so execution will halt here until someone tries to connect.
- ' Dim connClient As New ConnectedClient(incomingClient) 'Create a new instance of ConnectedClient (check its constructor to see whats happening now).
- Dim connClient As New ConnectedClient(incomingClient, Me) 'Create a new instance of ConnectedClient (check its constructor to see whats happening now).
- AddHandler connClient.dataReceived, AddressOf Me.MessageReceived
- ' clients.Add(New ConnectedClient(incomingClient)) 'Adds the connected client to the list of connected clients.
- clients.Add(connClient) 'Adds the connected client to the list of connected clients.
- ' AddHandler connClient.dataReceived, AddressOf Me.MessageReceived
- Loop
- End Sub
- Public Sub removeClient(ByVal client As ConnectedClient)
- If clients.Contains(client) Then
- clients.Remove(client)
- For x = 0 To lbClients.Items.Count - 1
- If lbClients.Items.Item(x) = client.Username Then RemoveClientFromListBox(x) : Exit For
- Next
- End If
- End Sub
- Private Sub RemoveClientFromListBox(ByVal IndexOfClient As String)
- If lbClients.InvokeRequired Then
- Me.Invoke(New StringDelegate(AddressOf RemoveClientFromListBox), IndexOfClient)
- Else
- lbClients.Items.Remove(lbClients.Items.Item(Val(IndexOfClient)))
- End If
- End Sub
- Private Sub BtnListen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnListen.Click
- If txtPort.Text = "" Or txtUserName.Text = "" Or IsNumeric(txtPort.Text) = False Or txtUserName.Text.IndexOf("|") >= 0 Then MsgBox("Fill text boxes properly") : Exit Sub
- listener = New System.Net.Sockets.TcpListener(System.Net.IPAddress.Any, txtPort.Text) 'The TcpListener will listen for incoming connections at port 43001
- listener.Start() 'Start listening.
- listenThread = New System.Threading.Thread(AddressOf DoListen) 'This thread will run the doListen method
- listenThread.IsBackground = True 'Since we dont want this thread to keep on running after the application closes, we set isBackground to true.
- listenThread.Start() 'Start executing doListen on the worker thread.
- txtPort.Enabled = False
- BtnListen.Enabled = False
- txtUserName.Enabled = False
- End Sub
- Private Sub MessageReceived(ByVal sender As ConnectedClient, ByVal Message As String) 'A message has been received from one of the clients. 'To determine who its from, use the sender object. 'sender.SendMessage can be used to reply to the sender.
- ' If Mid(Message, 1, 1) = "/" Then
- ' Select Case Mid(Message, 2, 8)
- ' Case "Connect:"
- ' sender.SendMessage("/Connected")
- ' SetConnectionLabelText("Connected")
- ' Case Else
- ' WriteToMainText(Message)
- ' End Select
- ' End If
- Dim data() As String = Message.Split("|"c)
- Select Case data(0)
- Case "/CONNECT"
- If GetClientByName(data(1)) Is Nothing Then
- sender.Username = data(1)
- AddClientToListBox(data(1))
- End If
- SetConnectionLabelText("Connected")
- sender.SendMessage("/Connected")
- Case "/DISCONNECT"
- removeClient(sender)
- Case Else
- WriteToMainText(Message & vbCrLf)
- End Select
- End Sub
- Private Function GetClientByName(ByVal name As String) As ConnectedClient
- For Each cc As ConnectedClient In clients
- If cc.Username = name Then
- Return cc 'client found, return it
- End If
- Next
- Return Nothing
- End Function
- Private Sub AddClientToListBox(ByVal ClientName As String)
- If lbClients.InvokeRequired Then
- Me.Invoke(New StringDelegate(AddressOf AddClientToListBox), ClientName)
- Else
- lbClients.Items.Add(ClientName)
- If (lbClients.SelectedIndex < 0) And (lbClients.Items.Count > 0) Then lbClients.SelectedIndex = 0
- End If
- End Sub
- Private Sub WriteToMainText(ByVal Message As String)
- If txtMain.InvokeRequired Then
- Me.Invoke(New StringDelegate(AddressOf WriteToMainText), Message)
- Else
- ' Dim Usr As String
- ' Usr = Mid(Message, 1, Message.IndexOf("|"))
- txtMain.Text = txtMain.Text & Message
- txtMain.SelectionStart = txtMain.Text.Length
- End If
- End Sub
- Private Sub SetConnectionLabelText(ByVal text As String)
- If Me.LblConnection.InvokeRequired Then
- Me.Invoke(New StringDelegate(AddressOf SetConnectionLabelText), text)
- Else
- Me.LblConnection.Text = text
- BtnListen.Enabled = False
- BtnSend.Enabled = True
- btnSendAll.Enabled = True
- txtSend.Enabled = True
- End If
- End Sub
- Private Sub BtnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSend.Click
- If txtSend.Text <> "" And lbClients.SelectedIndex >= 0 Then
- Dim cc As ConnectedClient
- cc = GetClientByName(Convert.ToString(lbClients.SelectedItem))
- cc.SendMessage(txtUserName.Text & ": " & txtSend.Text)
- WriteToMainText(txtUserName.Text & ": " & txtSend.Text & vbCrLf)
- txtSend.Text = ""
- End If
- End Sub
- Private Sub btnSendAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSendAll.Click
- If txtSend.Text <> "" Then
- For Each cc As ConnectedClient In clients
- cc.SendMessage(txtUserName.Text & ": " & txtSend.Text)
- WriteToMainText(txtUserName.Text & ": " & txtSend.Text & vbCrLf)
- Next
- txtSend.Text = ""
- End If
- End Sub
- Private Sub txtSend_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtSend.Enter
- Me.AcceptButton = BtnSend
- End Sub
- End Class
- Public Class ConnectedClient
- Private mClient As System.Net.Sockets.TcpClient
- Private Const BYTES_TO_READ As Integer = 255
- Private readBuffer(BYTES_TO_READ) As Byte
- Private mUsername As String
- Private mParentForm As frmMainServer
- Public Event dataReceived(ByVal sender As ConnectedClient, ByVal message As String)
- Sub New(ByVal client As System.Net.Sockets.TcpClient, ByVal parentForm As frmMainServer)
- mParentForm = parentForm
- mClient = client
- mClient.GetStream.BeginRead(readBuffer, 0, BYTES_TO_READ, AddressOf doRead, Nothing) 'This will start reading from the stream between this server and the connected client.
- End Sub
- Public Property Username() As String
- Get
- Return mUsername
- End Get
- Set(ByVal value As String)
- mUsername = value
- End Set
- End Property
- Private Sub doRead(ByVal ar As System.IAsyncResult)
- Dim totalRead As Integer
- Try
- totalRead = mClient.GetStream.EndRead(ar) 'Ends the reading and returns the number of bytes read.
- Catch ex As Exception
- mParentForm.removeClient(Me)
- Exit Sub
- 'The underlying socket have probably been closed OR an error has occured whilst trying to access it, either way, this is where you should remove close all eventuall connections
- 'to this client and remove it from the list of connected clients.
- End Try
- If totalRead > 0 Then
- 'the readBuffer array will contain everything read from the client.
- Dim receivedString As String = System.Text.Encoding.UTF8.GetString(readBuffer, 0, totalRead)
- RaiseEvent dataReceived(Me, receivedString)
- End If
- Try
- mClient.GetStream.BeginRead(readBuffer, 0, BYTES_TO_READ, AddressOf doRead, Nothing) 'Begin the reading again.
- Catch ex As Exception
- 'The underlying socket have probably been closed OR an error has occured whilst trying to access it, either way, this is where you should remove close all eventuall connections
- 'to this client and remove it from the list of connected clients.
- End Try
- End Sub
- Public Sub SendMessage(ByVal msg As String)
- Dim sw As IO.StreamWriter
- Try
- sw = New IO.StreamWriter(mClient.GetStream) 'Create a new streamwriter that will be writing directly to the networkstream.
- sw.Write(msg)
- sw.Flush()
- Catch ex As Exception
- MessageBox.Show(ex.ToString)
- End Try
- 'As opposed to writing to a file, we DONT call close on the streamwriter, since we dont want to close the stream.
- End Sub
- End Class
- SOUND MANIPULATION :
- Option Strict Off
- Option Explicit On
- Friend Class MP3Class
- '
- Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer
- Public Declare Function auxGetVolume Lib "winmm.dll" (ByVal uDeviceID As Long, ByVal lpdwVolume As Long) As Long
- Public Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Integer) As Integer
- Public MP3File As String
- Dim TheFile As String
- Dim movieBox As PictureBox
- Public retVal As Integer ' used to store our return value from the mci interface
- Private retData As String = Space$(128) ' used to store our return data from various commands
- Private _volLevel As Integer = Nothing
- Private _dMS As Integer = Nothing
- Private _dSec As Integer = Nothing
- Private _fDur As String = Nothing
- Private _posMS As Integer = Nothing
- Private _posSec As Integer = Nothing
- Private _fPos As String = Nothing
- Private _rChanValue As Boolean = False
- Private _lChanValue As Boolean = False
- Private _tRemainingMS As Integer = Nothing
- Private _tRemainingSec As Integer = Nothing
- Private _fTRemaining As String = Nothing
- Private _muteOutput As Boolean = False
- Public Function MP3Playing() As Boolean
- On Error GoTo TheError
- Static s As New Integer()
- mciSendString("status " & TheFile & " mode", s.Equals(30), Len(s.Equals(30)), 0)
- MP3Playing = (Mid(s.Equals(30), 1, 7) = "playing")
- Exit Function
- TheError: MsgBox(Err.Description, , " Error")
- End Function
- Public Function MP3SavePlayList(ByRef TheFile As String, ByRef playlist As ListBox) As Object
- On Error GoTo TheError
- Dim i As Short
- Dim a As String
- FileOpen(1, TheFile, OpenMode.Output)
- For i = 0 To playlist.Items.Count - 1
- a = playlist.Items(i)
- PrintLine(1, a)
- Next
- FileClose(1)
- Exit Function
- TheError: MsgBox(Err.Description, , " Error")
- End Function
- Public Function MP3OpenPlayList(ByRef TheFile As String, ByRef playlist As ListBox) As Object
- On Error GoTo TheError
- Dim test As String
- If TheFile = "" Then Exit Function
- FileOpen(1, TheFile, OpenMode.Input)
- While Not EOF(1)
- test = LineInput(1)
- playlist.Items.Add(RTrim(test))
- End While
- FileClose(1)
- Exit Function
- TheError: MsgBox(Err.Description, , " Error")
- End Function
- Public Function GetLastBackSlash(ByRef text As String) As String
- On Error GoTo TheError
- Dim i As Object
- Dim pos As Short
- Dim lastslash As Short
- For i = 1 To Len(text)
- pos = InStr(i, text, "\", CompareMethod.Text)
- If pos <> 0 Then lastslash = pos
- Next i
- GetLastBackSlash = Right(text, Len(text) - lastslash)
- Exit Function
- TheError: MsgBox(Err.Description, , " Error")
- End Function
- 'Take the path and .mp3 off the file
- Public Sub ListNoChar(ByRef playlist As System.Windows.Forms.ListBox, ByVal playlistPath As System.Windows.Forms.ListBox)
- On Error GoTo TheError
- Dim X As Object
- Dim NoChar As String
- Dim NoEnd As String
- For X = 0 To playlistPath.Items.Count - 1
- NoChar = GetLastBackSlash(playlistPath.Items(X))
- NoEnd = RightLeft(NoChar, ".")
- 'NoEnd = Mid(NoChar, 1, 1)
- playlist.Items.Add(playlist.Items.Count + 1 & ". " & NoEnd)
- Next X
- Exit Sub
- TheError: MsgBox(Err.Description, , " Error")
- End Sub
- Function GetFileExtension(ByVal strFileName As String) As String
- Dim lngPosition As Long
- lngPosition = InStrRev(strFileName, ".")
- If lngPosition Then
- GetFileExtension = Mid$(strFileName, lngPosition + 1)
- End If
- End Function
- Public Function RightLeft(ByRef source As String, ByRef token As String) As String
- On Error GoTo TheError
- Dim i As Short
- RightLeft = ""
- '
- For i = Len(source) To 1 Step -1
- '
- If Mid(source, i, 1) = token Then
- RightLeft = Left(source, i - 1)
- Exit Function
- End If
- Next i
- Exit Function
- TheError: MsgBox(Err.Description, , " Error")
- End Function
- Private Function NoEndChar(ByRef playlistPath As System.Windows.Forms.ListBox) As String
- On Error GoTo TheError
- Dim N As Object
- For N = 0 To playlistPath.Items.Count - 1
- Next N
- Exit Function
- TheError: MsgBox(Err.Description, , " Error")
- End Function
- Sub MP3Play()
- mciSendString("close " & TheFile, CStr(0), 0, 0)
- TheFile = Chr(34) & Trim(MP3File) & Chr(34)
- mciSendString("open " & TheFile, CStr(0), 0, 0)
- mciSendString("play " & TheFile, "", 0, 0)
- Exit Sub
- TheError: MsgBox(Err.Description, , " Error")
- End Sub
- Sub MP3Stop()
- TheFile = Chr(34) & Trim(MP3File) & Chr(34)
- mciSendString("close " & TheFile, CStr(0), 0, 0)
- Exit Sub
- TheError: MsgBox(Err.Description, , " Error")
- End Sub
- Sub MP3Resume()
- TheFile = Chr(34) & Trim(MP3File) & Chr(34)
- mciSendString("play " & TheFile, "", 0, 0)
- Exit Sub
- TheError: MsgBox(Err.Description, , " Error")
- End Sub
- Sub MP3Pause()
- TheFile = Chr(34) & Trim(MP3File) & Chr(34)
- Call mciSendString("Stop " & TheFile, CStr(0), 0, 0)
- Exit Sub
- TheError: MsgBox(Err.Description, , " Error")
- End Sub
- Public ReadOnly Property durationInMS() As Integer
- 'get duration of the song in milli-seconds
- Get
- Dim totalTime As String = Space(128)
- mciSendString("status " & TheFile & " length", totalTime, 128, 0)
- _dMS = Val(totalTime)
- durationInMS = _dMS
- totalTime = Nothing
- _dMS = Nothing
- End Get
- End Property
- Public ReadOnly Property durationInSec() As Integer
- 'get the duration of the song in seconds
- Get
- _dSec = durationInMS / 1000
- durationInSec = _dSec
- _dSec = Nothing
- End Get
- End Property
- Public ReadOnly Property formatDuration() As String
- 'get the duration of a song in a user friendly format, ex: 5:54
- Get
- Dim stat As String = Space(128) '128 space string buufer
- Dim totalTime As Integer = Nothing
- mciSendString("set " & TheFile & " time format ms", stat, 128, 0)
- mciSendString("status " & TheFile & " length", stat, 128, 0)
- totalTime = Val(stat)
- _fDur = getThisTime(totalTime)
- formatDuration = _fDur
- stat = Nothing
- totalTime = Nothing
- _fDur = Nothing
- End Get
- End Property
- Public Property positionInMS() As Integer
- 'get the current playing position in milli-seconds
- Get
- Dim stat As String = Space(128) 'buffer with 128 spaces available
- mciSendString("set " & TheFile & " time format milliseconds", 0, 0, 0)
- mciSendString("status " & TheFile & " position", stat, 128, 0)
- _posMS = Val(stat)
- positionInMS = _posMS
- stat = Nothing
- _posMS = Nothing
- End Get
- Set(ByVal Value As Integer)
- Try
- retVal = mciSendString("set " & TheFile & " time format ms", 0, 0, 0)
- If MP3Playing() = False Then
- mciSendString("play " & TheFile & " from " & Value, 0, 0, 0)
- Else
- mciSendString("seek " & TheFile & " to " & Value, 0, 0, 0)
- End If
- Catch exc As Exception
- MessageBox.Show(exc.Message, " Error", MessageBoxButtons.OK)
- End Try
- End Set
- End Property
- Public ReadOnly Property positionInSec() As Integer
- 'get the current playing position in seconds
- Get
- Dim pos As Integer
- _posSec = Val(positionInMS / 1000)
- positionInSec = _posSec
- _posSec = Nothing
- End Get
- End Property
- Public ReadOnly Property formatPosition() As String
- 'get the current playing position in a user-friendly format, ex - 1:12
- Get
- Dim sec As Integer = Nothing
- Dim mins As Integer = Nothing
- sec = Val(positionInSec())
- If sec < 60 Then _fPos = "0:" & Format(sec, "00")
- If sec > 59 Then
- mins = Int(sec / 60)
- sec = sec - (mins * 60)
- _fPos = Format(mins, "0") & ":" & Format(sec, "00")
- End If
- formatPosition = _fPos
- sec = Nothing
- mins = Nothing
- _fPos = Nothing
- End Get
- End Property
- Private Function getThisTime(ByVal timein As Integer) As String
- 'used to format the position and duration propertys to a user friendly
- 'format. ex: :49, 9:02, ect...
- Dim conH As Integer
- Dim conM As Integer
- Dim conS As Integer
- Dim remTime As Integer
- Dim strRetTime As String
- Try
- remTime = timein / 1000
- conH = Int(remTime / 3600)
- remTime = remTime Mod 3600
- conM = Int(remTime / 60)
- remTime = remTime Mod 60
- conS = remTime
- If conH > 0 Then
- strRetTime = Trim(Str(conH)) & ":"
- Else
- strRetTime = ""
- End If
- If conM >= 10 Then
- strRetTime = strRetTime & Trim(Str(conM))
- ElseIf conM > 0 Then
- strRetTime = strRetTime & Trim(Str(conM))
- Else
- strRetTime = strRetTime & "0"
- End If
- strRetTime = strRetTime & ":"
- If conS >= 10 Then
- strRetTime = strRetTime & Trim(Str(conS))
- ElseIf conS > 0 Then
- strRetTime = strRetTime & "0" & Trim(Str(conS))
- Else
- strRetTime = strRetTime & "00"
- End If
- getThisTime = strRetTime
- 'clean up all variables
- conH = Nothing
- conM = Nothing
- conS = Nothing
- remTime = Nothing
- strRetTime = Nothing
- Catch exc As Exception
- MessageBox.Show(exc.Message, " Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
- End Try
- End Function
- Public ReadOnly Property timeRemainingInMS() As Integer
- 'get the time remaining in milli-seconds
- Get
- _tRemainingMS = durationInMS - positionInMS
- timeRemainingInMS = _tRemainingMS
- _tRemainingMS = Nothing
- End Get
- End Property
- Public ReadOnly Property timeRemainingInSec() As Integer
- 'get the time remaining in seconds
- Get
- _tRemainingSec = durationInSec - positionInSec
- timeRemainingInSec = _tRemainingSec
- _tRemainingSec = Nothing
- End Get
- End Property
- Public ReadOnly Property formatTimeRemaining() As String
- 'get the time remaining in a user friendly format - ex. 3:50
- Get
- _fTRemaining = getThisTime(timeRemainingInMS)
- formatTimeRemaining = _fTRemaining
- _fTRemaining = Nothing
- End Get
- End Property
- Public Property volumeLevel() As Integer
- 'set - the sound volume level
- 'get - the current sound volume level value
- '
- 'note: 1000 = max volume | 0 = minimum volume value
- Get
- Dim theLevel As String = Space(128) '128 space buffer
- mciSendString("status " & TheFile & " volume", theLevel, 128, 0)
- _volLevel = Val(theLevel)
- volumeLevel = _volLevel
- theLevel = Nothing
- _volLevel = Nothing
- End Get
- Set(ByVal Value As Integer)
- mciSendString("setaudio " & TheFile & " volume to " & Value, 0, 0, 0)
- End Set
- End Property
- Public Property muteSoundOutput() As Boolean
- 'set - turn the sound on or off
- 'get - check if the sound is on or off
- Get
- muteSoundOutput = _muteOutput
- End Get
- Set(ByVal Value As Boolean)
- If Value = True Then
- mciSendString("setaudio " & TheFile & " off", 0, 0, 0)
- _muteOutput = Value
- Else
- mciSendString("setaudio " & TheFile & " on", 0, 0, 0)
- _muteOutput = Value
- End If
- End Set
- End Property
- End Class
- vb.net volume meter :
- contians the walkthrough to get volume meter level at realtime from a usb microphone. also you can search wikipedia
- for speech recognition.
- here is the vumeter tutorial incase the link gives you problems:
- 'start of tutorial
- Introduction
- volume meter in vb.net tested working gets the audio level from usb microphone (in 2 channels)
- at realtime
- utilizing directx
- tested on vb 2008 express edition win xp pro sp3 .net 3.5
- Background
- the credit goes to 2 very good programers :
- 1 nigel ealand, who evolved the code to work in vb 2008
- 2 jacob klint the original poster of the code in codeguru at the link:
- http://www.codeproject.com/KB/direct...87#xx3514687xx
- Using the code
- form controls (designer) :
- 1 ComboBox name : ComboBox1
- 2 button name : FindButton
- 3 button name : StartButton
- 4 progressbar name : ProgressBar1 maximum : 32770
- 5 progressbar name : ProgressBar2 maximum : 32770
- download directx 9 sdk from the link :
- http://www.microsoft.com/downloads/d...displaylang=en[^]
- install, restart comuter, connect usb microphone with drivers installed from its cd (auto plug n play install might not suffice)
- paste source code (in the end of this text) or
- sln file : http://www.esac.org.uk/VUTest.zip[^] if your lazy
- project, add reference, .net, microsoft.directx.sound
- disabling loader lock error (debug, exeptions, managed debuging assistants,
- uncheck loader lock (thrown))
- if not unchecked press debug again after exeption will have been thrown
- Imports System
- Imports System.Collections
- Imports System.ComponentModel
- Imports System.Drawing
- Imports System.Windows.Forms
- Imports Microsoft.DirectX.DirectSound
- Imports System.Threading
- Imports System.Collections.Specialized
- Public Class Sound_Card_Form
- Private Sub StartButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles FindButton.Click
- 'Dim MyVU As New VolumeMeter
- 'MyVU.Start()
- Start()
- End Sub
- Private Sub FindButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles FindButton.Click
- 'Dim MyVU As New VolumeMeter
- 'MyVU.FindDevices()
- FindDevices()
- End Sub
- ' Public Class VolumeMeter
- 'Inherits System.Windows.Forms.UserControl
- 'Public Delegate Sub VolumeChangedEventHandler(ByVal vcea As VolumeChangedEventArgs)
- 'Public Event VolumeChanged As VolumeChangedEventHandler
- Private Const SAMPLES As Integer = 8
- Private Shared SAMPLE_FORMAT_ARRAY As Integer() = {SAMPLES, 2, 1}
- Public Shared audioDevices As CaptureDevicesCollection
- Private Shared m_deviceNames As StringCollection
- Private deviceName As String = "(none)"
- Private deviceIndex As Integer = -1
- Private buffer As Microsoft.DirectX.DirectSound.CaptureBuffer
- Private liveVolumeThread As System.Threading.Thread
- Private m_sampleDelay As Integer = 100
- Private m_frameDelay As Integer = 10
- Private m_autoStart As Boolean = True
- 'Private components As System.ComponentModel.Container = Nothing
- Public Sub FindDevices()
- Dim audioDevices As New CaptureDevicesCollection
- Dim x As Integer = 0
- While x < audioDevices.Count
- ComboBox1.Items.Add(audioDevices.Item(x).Description)
- x = x + 1
- End While
- ComboBox1.SelectedIndex = 0
- End Sub
- Public Sub Start()
- [Stop]()
- Dim audioDevices As New CaptureDevicesCollection
- deviceIndex = ComboBox1.SelectedIndex
- If deviceIndex <> -1 Then
- ' initialize the capture buffer and start the animation thread
- Dim cap As New Capture(audioDevices(deviceIndex).DriverGuid)
- Dim desc As New CaptureBufferDescription()
- Dim wf As New WaveFormat()
- wf.BitsPerSample = 16
- wf.SamplesPerSecond = 44100
- wf.Channels = 2
- wf.BlockAlign = CShort(wf.Channels * wf.BitsPerSample / 8)
- wf.AverageBytesPerSecond = wf.BlockAlign * wf.SamplesPerSecond
- wf.FormatTag = WaveFormatTag.Pcm
- desc.Format = wf
- desc.BufferBytes = SAMPLES * wf.BlockAlign
- buffer = New Microsoft.DirectX.DirectSound.CaptureBuffer(desc, cap)
- buffer.Start(True)
- ' Start a seperate thread to read the buffer and update the progress bars
- liveVolumeThread = New Thread(AddressOf updateProgress) 'Thread starts at updateProgress
- Control.CheckForIllegalCrossThreadCalls = False ' This is needed otherwise the form will not update
- liveVolumeThread.Priority = ThreadPriority.Lowest ' Thread works in the background
- liveVolumeThread.Start()
- End If
- End Sub
- Public Sub [Stop]()
- If liveVolumeThread IsNot Nothing Then
- liveVolumeThread.Abort()
- liveVolumeThread.Join()
- liveVolumeThread = Nothing
- End If
- If buffer IsNot Nothing Then
- If buffer.Capturing Then
- buffer.[Stop]()
- End If
- buffer.Dispose()
- buffer = Nothing
- End If
- End Sub
- Public Sub updateProgress()
- While True
- Dim tempFrameDelay As Integer = m_frameDelay
- Dim tempSampleDelay As Integer = m_sampleDelay
- Dim samples__1 As Array = buffer.Read(0, GetType(Int16), LockFlag.FromWriteCursor, SAMPLE_FORMAT_ARRAY)
- ' for each channel, determine the step size necessary for each iteration
- Dim leftGoal As Integer = 0
- Dim rightGoal As Integer = 0
- ' Sum the 8 samples
- For i As Integer = 0 To SAMPLES - 1
- leftGoal += CType(samples__1.GetValue(i, 0, 0), Int16)
- rightGoal += CType(samples__1.GetValue(i, 1, 0), Int16)
- Next
- ' Calculate the average of the 8 samples
- leftGoal = CInt(Math.Abs(leftGoal \ SAMPLES))
- rightGoal = CInt(Math.Abs(rightGoal \ SAMPLES))
- Dim range1 As Double = leftGoal - ProgressBar1.Value ' calculates the difference between new and the current progress bar value
- Dim range2 As Double = rightGoal - ProgressBar2.Value
- ' Assign the exact current value to the progress bar
- Dim exactValue1 As Double = ProgressBar1.Value
- Dim exactValue2 As Double = ProgressBar2.Value
- Dim stepSize1 As Double = range1 / tempSampleDelay * tempFrameDelay
- ' Limit the value range to positive values
- If Math.Abs(stepSize1) < 0.01 Then
- stepSize1 = Math.Sign(range1) * 0.01
- End If
- Dim absStepSize1 As Double = Math.Abs(stepSize1)
- Dim stepSize2 As Double = range2 / tempSampleDelay * tempFrameDelay
- If Math.Abs(stepSize2) < 0.01 Then
- stepSize2 = Math.Sign(range2) * 0.01
- End If
- Dim absStepSize2 As Double = Math.Abs(stepSize2)
- ' increment/decrement the bars' values until both equal their desired goals,
- ' sleeping between iterations
- If (ProgressBar1.Value = leftGoal) AndAlso (ProgressBar2.Value = rightGoal) Then
- Thread.Sleep(tempSampleDelay)
- Else
- Do
- If ProgressBar1.Value <> leftGoal Then
- If absStepSize1 < Math.Abs(leftGoal - ProgressBar1.Value) Then
- exactValue1 += stepSize1
- ProgressBar1.Value = CInt(Math.Truncate(Math.Round(exactValue1)))
- 'This is the real value
- 'decibels = 20 * Log10(ProgressBar1.Value/ 32768.0)
- Else
- ProgressBar1.Value = leftGoal
- End If
- End If
- If ProgressBar2.Value <> rightGoal Then
- If absStepSize2 < Math.Abs(rightGoal - ProgressBar2.Value) Then
- exactValue2 += stepSize2
- ProgressBar2.Value = CInt(Math.Truncate(Math.Round(exactValue2)))
- Else
- ProgressBar2.Value = rightGoal
- End If
- End If
- Thread.Sleep(tempFrameDelay)
- Loop While (ProgressBar1.Value <> leftGoal) OrElse (ProgressBar2.Value <> rightGoal)
- End If
- End While
- End Sub
- End Class
- run : press button 1 , press button 2
- Points of Interest
- samples delay variables (in source code) :
- Private m_sampleDelay As Integer = 15 ' miliseconds
- Private m_frameDelay As Integer = 15
- look up in youtube: vb.net volume meter
- 'end of tutorial
- you can delete :
- Imports System.Collections
- Imports System.ComponentModel
- Imports System.Drawing
- Imports System.Windows.Forms
- microphones cd drivers need to be installed.
- take your time, this king of thing requires lazyness.
- GET JOYSTICK ARROWS PRESSED : (BY jo0ls)
- Create a new windows forms application.
- Use Project -> Add class to add a new class called "Joystick.vb"
- In the Joystick.vb code file, replace the existing code with the following:
- Imports System.ComponentModel
- Imports System.Runtime.InteropServices
- Public Class Joystick
- Inherits NativeWindow
- Private parent As Form
- Private Const MM_JOY1MOVE As Integer = &H3A0
- ' Public Event Move(ByVal joystickPosition As Point)
- Public btnValue As String
- Public Event Up()
- Public Event Down()
- Public Event Left()
- Public Event Right()
- <StructLayout(LayoutKind.Explicit)> _
- Private Structure JoyPosition
- <FieldOffset(0)> _
- Public Raw As IntPtr
- <FieldOffset(0)> _
- Public XPos As UShort
- <FieldOffset(2)> _
- Public YPos As UShort
- End Structure
- Private Class NativeMethods
- Private Sub New()
- End Sub
- ' This is a "Stub" function - it has no code in its body.
- ' There is a similarly named function inside a dll that comes with windows called
- ' winmm.dll.
- ' The .Net framework will route calls to this function, through to the dll file.
- <DllImport("winmm", CallingConvention:=CallingConvention.Winapi, EntryPoint:="joySetCapture", SetLastError:=True)> _
- Public Shared Function JoySetCapture(ByVal hwnd As IntPtr, ByVal uJoyID As Integer, ByVal uPeriod As Integer, <MarshalAs(UnmanagedType.Bool)> ByVal changed As Boolean) As Integer
- End Function
- End Class
- Public Sub New(ByVal parent As Form, ByVal joyId As Integer)
- AddHandler parent.HandleCreated, AddressOf Me.OnHandleCreated
- AddHandler parent.HandleDestroyed, AddressOf Me.OnHandleDestroyed
- AssignHandle(parent.Handle)
- Me.parent = parent
- Dim result As Integer = NativeMethods.JoySetCapture(Me.Handle, joyId, 100, True)
- End Sub
- Private Sub OnHandleCreated(ByVal sender As Object, ByVal e As EventArgs)
- AssignHandle(DirectCast(sender, Form).Handle)
- End Sub
- Private Sub OnHandleDestroyed(ByVal sender As Object, ByVal e As EventArgs)
- ReleaseHandle()
- End Sub
- Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
- If m.Msg = MM_JOY1MOVE Then
- ' Joystick co-ords.
- ' (0,0) (32768,0) (65535, 0)
- '
- '
- '
- ' (0, 32768) (32768, 32768) (65535, 32768)
- '
- '
- '
- '
- ' (0, 65535) (32768, 65535) (65535, 65535)
- '
- Dim p As JoyPosition
- p.Raw = m.LParam
- ' RaiseEvent Move(New Point(p.XPos, p.YPos))
- If p.XPos > 16384 AndAlso p.XPos < 49152 Then
- ' X is near the centre line.
- If p.YPos < 6000 Then
- ' Y is near the top.
- RaiseEvent Up()
- ElseIf p.YPos > 59536 Then
- ' Y is near the bottom.
- RaiseEvent Down()
- End If
- Else
- If p.YPos > 16384 AndAlso p.YPos < 49152 Then
- ' Y is near the centre line
- If p.XPos < 6000 Then
- ' X is near the left.
- RaiseEvent Left()
- ElseIf p.XPos > 59536 Then
- ' X is near the right
- RaiseEvent Right()
- End If
- End If
- End If
- End If
- If btnValue <> m.WParam.ToString Then
- btnValue = m.WParam.ToString
- End If
- MyBase.WndProc(m)
- End Sub
- End Class
- Now you can ignore the Joystick.vb code - you aren't supposed to be able to understand it on day 3 of learning VB.Net. Maybe on day 303...
- Now you can create an instance of the Joystick class in your Form1 class, and handle the events:
- add a timer and a label from the toolbox (in form1.vb[design] window)
- Public Class Form1
- ' This declares what Type the variable joystick1 will be for. The Type is Joystick.
- ' WithEvents allows you to easily add events using the IDE.
- Private WithEvents joystick1 As Joystick
- ' This is an event that belongs to the Form. It is raised when the form loads.
- Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
- ' Here we create the Joystick object. You must pass Me - which refers to this Form,
- ' and 0 - which is the Joystick id.
- joystick1 = New Joystick(Me, 0)
- End Sub
- ' And now we have the four events that belong to joystick1.
- Private Sub joystick1_Down() Handles joystick1.Down
- ' TODO: Replace this so that it plays a sound instead.
- Me.Text = "Down"
- End Sub
- Private Sub joystick1_Left() Handles joystick1.Left
- ' TODO: Replace this so that it plays a sound instead.
- Me.Text = "Left"
- End Sub
- Private Sub joystick1_Right() Handles joystick1.Right
- ' TODO: Replace this so that it plays a sound instead.
- Me.Text = "Right"
- End Sub
- Private Sub joystick1_Up() Handles joystick1.Up
- ' TODO: Replace this so that it plays a sound instead.
- Me.Text = "Up"
- End Sub
- ' Private Sub joystick1_buttonPressed() Handles joystick1.buttonPressed
- ' TODO: Replace this so that it plays a sound instead.
- ' Me.Text = joystick1.b1
- 'End Sub
- Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
- Label1.Text = joystick1.btnValue
- End Sub
- End Class
- A STRONG ENCRYPTION CLASS
- by Jenner :
- The first two simply encrypt and decrypt strings. You just provide the "key".
- The third turns a string into a hash. Very useful for passwords.
- The last compares a string against a hash. Perfect for login screens
- Imports System.Security.Cryptography
- Imports System.IO
- Imports System.Text
- Public Class clsCrypto
- 'Byte vector required for Rijndael. This is randomly generated and recommended you change it on a per-application basis.
- 'It is 16 bytes.
- Private bytIV() As Byte = {121, 241, 10, 1, 132, 74, 11, 39, 255, 91, 45, 78, 14, 211, 22, 62}
- 'Character to pad keys with to make them at least intMinKeySize.
- Private Const chrKeyFill As Char = "X"c
- 'String to display on error for functions that return strings. {0} is Exception.Message.
- Private Const strTextErrorString As String = "#ERROR - {0}"
- 'Min size in bytes of randomly generated salt.
- Private Const intMinSalt As Integer = 4
- 'Max size in bytes of randomly generated salt.
- Private Const intMaxSalt As Integer = 8
- 'Size in bytes of Hash result. MD5 returns a 128 bit hash.
- Private Const intHashSize As Integer = 16
- 'Size in bytes of the key length. Rijndael takes either a 128, 192, or 256 bit key.
- 'If it is under this, pad with chrKeyFill. If it is over this, truncate to the length.
- Private Const intKeySize As Integer = 32
- 'Encrypt a String with Rijndael symmetric encryption.
- Public Function EncryptString128Bit(ByVal strPlainText As String, ByVal strKey As String) As String
- Try
- Dim bytPlainText() As Byte
- Dim bytKey() As Byte
- Dim bytEncoded() As Byte
- Dim objMemoryStream As New MemoryStream
- Dim objRijndaelManaged As New RijndaelManaged
- strPlainText = strPlainText.Replace(vbNullChar, String.Empty)
- bytPlainText = Encoding.UTF8.GetBytes(strPlainText)
- bytKey = ConvertKeyToBytes(strKey)
- Dim objCryptoStream As New CryptoStream(objMemoryStream, _
- objRijndaelManaged.CreateEncryptor(bytKey, bytIV), _
- CryptoStreamMode.Write)
- objCryptoStream.Write(bytPlainText, 0, bytPlainText.Length)
- objCryptoStream.FlushFinalBlock()
- bytEncoded = objMemoryStream.ToArray
- objMemoryStream.Close()
- objCryptoStream.Close()
- Return Convert.ToBase64String(bytEncoded)
- Catch ex As Exception
- Return String.Format(strTextErrorString, ex.Message)
- End Try
- End Function
- 'Decrypt a String with Rijndael symmetric encryption.
- Public Function DecryptString128Bit(ByVal strCryptText As String, ByVal strKey As String) As String
- Try
- Dim bytCryptText() As Byte
- Dim bytKey() As Byte
- Dim objRijndaelManaged As New RijndaelManaged
- bytCryptText = Convert.FromBase64String(strCryptText)
- bytKey = ConvertKeyToBytes(strKey)
- Dim bytTemp(bytCryptText.Length) As Byte
- Dim objMemoryStream As New MemoryStream(bytCryptText)
- Dim objCryptoStream As New CryptoStream(objMemoryStream, _
- objRijndaelManaged.CreateDecryptor(bytKey, bytIV), _
- CryptoStreamMode.Read)
- objCryptoStream.Read(bytTemp, 0, bytTemp.Length)
- objMemoryStream.Close()
- objCryptoStream.Close()
- Return Encoding.UTF8.GetString(bytTemp).Replace(vbNullChar, String.Empty)
- Catch ex As Exception
- Return String.Format(strTextErrorString, ex.Message)
- End Try
- End Function
- 'Compute an MD5 hash code from a string and append any salt-bytes used/generated to the end.
- Public Function ComputeMD5Hash(ByVal strPlainText As String, Optional ByVal bytSalt() As Byte = Nothing) As String
- Try
- Dim bytPlainText As Byte() = Encoding.UTF8.GetBytes(strPlainText)
- Dim hash As HashAlgorithm = New MD5CryptoServiceProvider()
- If bytSalt Is Nothing Then
- Dim rand As New Random
- Dim intSaltSize As Integer = rand.Next(intMinSalt, intMaxSalt)
- bytSalt = New Byte(intSaltSize - 1) {}
- Dim rng As New RNGCryptoServiceProvider
- rng.GetNonZeroBytes(bytSalt)
- End If
- Dim bytPlainTextWithSalt() As Byte = New Byte(bytPlainText.Length + bytSalt.Length - 1) {}
- bytPlainTextWithSalt = ConcatBytes(bytPlainText, bytSalt)
- Dim bytHash As Byte() = hash.ComputeHash(bytPlainTextWithSalt)
- Dim bytHashWithSalt() As Byte = New Byte(bytHash.Length + bytSalt.Length - 1) {}
- bytHashWithSalt = ConcatBytes(bytHash, bytSalt)
- Return Convert.ToBase64String(bytHashWithSalt)
- Catch ex As Exception
- Return String.Format(strTextErrorString, ex.Message)
- End Try
- End Function
- 'Verify a string against a hash generated with the ComputeMD5Hash function above.
- Public Function VerifyHash(ByVal strPlainText As String, ByVal strHashValue As String) As Boolean
- Try
- Dim bytWithSalt As Byte() = Convert.FromBase64String(strHashValue)
- If bytWithSalt.Length < intHashSize Then Return False
- Dim bytSalt() As Byte = New Byte(bytWithSalt.Length - intHashSize - 1) {}
- Array.Copy(bytWithSalt, intHashSize, bytSalt, 0, bytWithSalt.Length - intHashSize)
- Dim strExpectedHashString As String = ComputeMD5Hash(strPlainText, bytSalt)
- Return strHashValue.Equals(strExpectedHashString)
- Catch ex As Exception
- Return Nothing
- End Try
- End Function
- 'Simple function to concatenate two byte arrays.
- Private Function ConcatBytes(ByVal bytA() As Byte, ByVal bytB() As Byte) As Byte()
- Try
- Dim bytX() As Byte = New Byte(((bytA.Length + bytB.Length)) - 1) {}
- Array.Copy(bytA, bytX, bytA.Length)
- Array.Copy(bytB, 0, bytX, bytA.Length, bytB.Length)
- Return bytX
- Catch ex As Exception
- Return Nothing
- End Try
- End Function
- 'A function to convert a string into a 32 byte key.
- Private Function ConvertKeyToBytes(ByVal strKey As String) As Byte()
- Try
- Dim intLength As Integer = strKey.Length
- If intLength < intKeySize Then
- strKey &= Strings.StrDup(intKeySize - intLength, chrKeyFill)
- Else
- strKey = strKey.Substring(0, intKeySize)
- End If
- Return Encoding.UTF8.GetBytes(strKey)
- Catch ex As Exception
- Return Nothing
- End Try
- End Function
- End Class
Add Comment
Please, Sign In to add comment