Private Sub ListBox1_MouseDown(sender As Object, e As MouseEventArgs) Handles ListBox1.MouseDown
If Not ListBox1.SelectedItem = "" Then
Timer1.Stop()
If e.Button = Windows.Forms.MouseButtons.Right Then
ContextMenuStrip1.Show(MousePosition)
ListBox1.SelectedIndex = ListBox1.IndexFromPoint(e.X, e.Y)
selt = ListBox1.SelectedItem
apksv = (Adb("/c adb shell pm path " + selt)).Replace("package:", "")
Dim spl As String() = apksv.Split("/"c)
For Each s As String In spl
tempout.Text = s
Next
apkl = Environment.CurrentDirectory + "\adb\" + tempout.Text
End If
End If
Timer1.Start()
End Sub
Private Sub SaveToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SaveToolStripMenuItem.Click
Timer1.Stop()
Finalout.Text = Adb("/c adb pull " + apksv)
With FolderBrowserDialog1
If .ShowDialog() = DialogResult.OK Then
If File.Exists(apkl) Then
File.Move(apkl, .SelectedPath + "\" + tempout.Text)
Else
Finalout.Text = "Not moved " + apkl
End If
End If
End With
Timer1.Start()
End Sub
End Class
File.Exists(apkl) Not working i cant find a solution
Related
Can a WebBrowser.DocumentCompleted event executes the BackgroundWorker.RunWorkerAsync() correctly? Because my program doesn't seem to execute the codes under BackgroundWorker.
Code:
Dim Status As String = ""
Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
If Status = "Enabled" Or Status = "Disabled" Then
Else
Status = WebBrowser1.Document.GetElementById(Account & "Flag").InnerText.ToString
If Status = "Enabled" Then
BackgroundWorker1.RunWorkerAsync()
ElseIf Status = "Disabled" Then
MessageBox.Show("disabled. Contact admin for more information.", "JKLorenzo", MessageBoxButtons.OK, MessageBoxIcon.Information)
Close()
End If
End If
End Sub
I finally made it to work
Here is the code i've used:
Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
BackgroundWorker1.ReportProgress(10)
Dim mysqlconnection As MySqlConnection = New MySqlConnection("server=85.10.205.173;port=3306;username='" & User & "';password='" & Pass & "'")
BackgroundWorker1.ReportProgress(20)
Dim mysqlcommand As MySqlCommand = Nothing
BackgroundWorker1.ReportProgress(30)
Dim mysqldatareader As MySqlDataReader = Nothing
BackgroundWorker1.ReportProgress(40)
mysqlconnection.Open()
BackgroundWorker1.ReportProgress(50)
Using table As DataTable = New DataTable
BackgroundWorker1.ReportProgress(60)
Using command As MySqlCommand = New MySqlCommand("Select * from my.accounts where Username = 'Ray';", mysqlconnection)
BackgroundWorker1.ReportProgress(70)
Using adapter As MySqlDataAdapter = New MySqlDataAdapter(command)
BackgroundWorker1.ReportProgress(80)
adapter.Fill(table)
BackgroundWorker1.ReportProgress(90)
End Using
End Using
For Each row As DataRow In table.Rows
If row("Flag") = "enable" Then
e.Result = "1"
BackgroundWorker1.ReportProgress(100)
Else
e.Result = "0"
BackgroundWorker1.ReportProgress(100)
End If
Next
End Using
mysqlconnection.Close()
End Sub
Private Sub BackgroundWorker1_ProgressChanged(sender As Object, e As ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged
If e.ProgressPercentage = 10 Then
Label1.Text = "Status: Checking"
Label1.ForeColor = Color.FromKnownColor(KnownColor.Highlight)
End If
ProgressBar1.Value = e.ProgressPercentage
ProgressBar1.Refresh()
End Sub
Private Sub BackgroundWorker1_RunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
Threading.Thread.Sleep(500)
ProgressBar1.Value = 0
If e.Result = "1" Then
Label1.Text = "Status: Enabled"
Label1.ForeColor = Color.Green
Button1.Enabled = False
Button2.Enabled = True
ElseIf e.Result = "0" Then
Label1.Text = "Status: Disabled"
Label1.ForeColor = Color.OrangeRed
Button1.Enabled = True
Button2.Enabled = False
Else
MessageBox.Show("Unknown output: " & e.Result & " . Closing", "", MessageBoxButtons.OK, MessageBoxIcon.Error)
Close()
End If
End Sub
i want to display my datagridview1 data in relevant textboxes. when i select any cell in the datagridview1 relevant data should be displayed in textboxes.
here is the code i did
Private Sub DataGridView1_CellClick(ByVal sender As Object, _
ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) _
Handles DataGridView1.CellClick
Dim i As Integer
i = DataGridView1.CurrentRow.Index
Me.Label8.Text = DataGridView1.Item(0, i).Value
Me.TextBox1.Text = DataGridView1.Item(1, i).Value
Me.TextBox2.Text = DataGridView1.Item(2, i).Value
Me.ComboBox1.Text = DataGridView1.Item(3, i).Value
Me.ComboBox2.Text = DataGridView1.Item(4, i).Value
Me.TextBox5.Text = DataGridView1.Item(5, i).Value
Me.TextBox3.Text = DataGridView1.Item(6, i).Value
Me.TextBox4.Text = DataGridView1.Item(7, i).Value
Me.RichTextBox1.Text = DataGridView1.Item(8, i).Value
Me.RichTextBox2.Text = DataGridView1.Item(9, i).Value
Me.Label14.Text = DataGridView1.Item(10, i).Value
End Sub
i did another code here it is
Private Sub DataGridView1_CellContentClick(ByVal sender _
As System.Object, ByVal e As _
System.Windows.Forms.DataGridViewCellEventArgs) _
Handles DataGridView1.CellContentClick
Try
If e.RowIndex >= 0 Then
Dim row As DataGridViewRow
row = Me.DataGridView1.Rows(e.RowIndex)
Label8.Text = row.Cells("id").Value.ToString
TextBox1.Text = row.Cells("firstname").Value.ToString
TextBox2.Text = row.Cells("lastname").Value.ToString
ComboBox1.Text = row.Cells("year").Value.ToString
ComboBox2.Text = row.Cells("month").Value.ToString
TextBox5.Text = row.Cells("gender").Value.ToString
TextBox3.Text = row.Cells("address").Value.ToString
TextBox4.Text = row.Cells("telephone").Value.ToString
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
however both codes are not working they give errors. inside the "" marks represent the column name
can anyone give me the solution in vb.net
Private Sub DataGridView1_CellClick (ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
Dim i As Integer
With DataGridView1
if e.RowIndex >= 0 Then
i = .CurrentRow.Index
tbID.text = .Rows(i).Cells("id").Value.ToString
tbFirstNametext = .Rows(i).Cells("firstname").Value.ToString
tbLastNametext = .Rows(i).Cells("lastname").Value.ToString
tbAddresstext = .Rows(i).Cells("address").Value.ToString
End If
End With
End Sub
Please use this,
Private Sub DataGridView1_CellContentClick_1(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellDoubleClick
namatxt.Text = Me.DataGridView1.SelectedCells(1).Value.ToString
End Sub
How about this?
Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
Dim row As DataGridViewRow = DataGridView1.CurrentRow
Me.Label8.Text = row.Cells(0).Value.ToString()
Me.TextBox1.Text = row.Cells(1).Value.ToString()
Me.TextBox2.Text = row.Cells(2).Value.ToString()
Me.ComboBox1.Text = row.Cells(3).Value.ToString()
Me.ComboBox2.Text = row.Cells(4).Value.ToString()
Me.TextBox5.Text = row.Cells(5).Value.ToString()
Me.TextBox3.Text = row.Cells(6).Value.ToString()
Me.TextBox4.Text = row.Cells(7).Value.ToString()
Me.RichTextBox1.Text = row.Cells(8).Value.ToString()
Me.RichTextBox2.Text = row.Cells(9).Value.ToString()
Me.Label14.Text = row.Cells(10).Value.ToString()
End Sub
Use this code, it works fine for me:
Private Sub DataGridView1_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellClick
If e.RowIndex >= 0 Then
Dim row As DataGridViewRow
row = Me.DataGridView1.Rows(e.RowIndex)
tbID.Text = row.Cells("id").Value.ToString
tbFirstName.Text = row.Cells("firstname").Value.ToString
tbLastName.Text = row.Cells("lastname").Value.ToString
tbAddress.Text = row.Cells("address").Value.ToString
End If
End Sub
replace the names of the columns i have (i.e "id" "firstname" "lastname") etc with the name of your columns.
To navigate through DataGridView rows with up and down keys and show the selected record in textboxes you can use this:
'declare variable
Private DB As New databasenameDataSetTableAdapters.tablenameTableAdapter
'add constructor to your form
Public Sub New()
' This call is required by the designer.
InitializeComponent()
'Setting KeyPreview To True makes sure that the Form1_KeyDown will always
'be called If a key Is pressed,
Me.KeyPreview = True
End Sub
Private Sub form1_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
Select Case e.KeyCode
'if else statement is there otherwise when going through the rows in grid
'it would show the previous row in textboxes instead of current one
'GetData is a select query you can generate by double clicking the dataset.xsd file in solution explorer
Case Keys.Up
Dim rowUp As Integer = dataGridView.CurrentRow.Index
If (rowUp <= 0) Then
rowUp = 0
Else
rowUp = rowUp - 1
End If
Try
txtBox1.Text = DB.GetData.Rows(rowUp).Item(0).ToString
txtBox2.Text = DB.GetData.Rows(rowUp).Item(1).ToString
txtBox3.Text = DB.GetData.Rows(rowUp).Item(2).ToString
Catch ex As Exception
MsgBox(ex.Message)
End Try
Exit Select
Case Keys.Down
Dim rowDown As Integer = dataGridView.CurrentRow.Index
If (rowDown >= DB.GetData.Rows.Count - 1) Then
rowDown = DB.GetData.Rows.Count - 1
Else
rowDown = rowDown + 1
End If
Try
txtBox1.Text = DB.GetData.Rows(rowDown).Item(0).ToString
txtBox2.Text = DB.GetData.Rows(rowDown).Item(1).ToString
txtBox3.Text = DB.GetData.Rows(rowDown).Item(2).ToString
Catch ex As Exception
MsgBox(ex.Message)
End Try
Exit Select
Another way of doing it use the datagridview CellEnter event
Private Sub DataGridView1_CellEnter(sender As Object, e As EventArgs)
Handles DataGridView1.CellEnter
Dim row As DataGridViewRow = DataGridView1.CurrentRow
txtBox1.Text = row.Cells(0).Value.ToString()
txtBox2.Text = row.Cells(1).Value.ToString(),
End Sub
Private Sub DataGridView1_CellEnter(sender As Object, e As EventArgs)
Handles DataGridView1.CellEnter
Dim row As DataGridViewRow = DataGridView1.CurrentRow
txtBox1.Text = row.Cells(0).Value.ToString()
txtBox2.Text = row.Cells(1).Value.ToString(),
End Sub
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I'm writing some code for a calculator and I keep getting this error. I have the math functions in another class but the variables from form1 are not accessible. Below is my code.
I've also tried changing my Dim variables to public but that also doesn't work.
Public Class Form1
'create a value to keep track of whether the calculation is complete so the calculator can revert to zero for new calculations
Dim state As Integer
'create values to store information on numbers and signs entered as well as the answer returned
Dim one As Double
Dim two As Double
Dim ans As Double
Dim sign As Char
Public Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'when "Return" or "Enter" Key is selected button 15 is clicked (seems to only work when textbox selected????)
Me.AcceptButton = Button15
'change the title of the form
Me.Text = "Simple Calculator"
'label the buttons logically
Button1.Text = "1"
Button2.Text = "2"
Button3.Text = "3"
Button4.Text = "4"
Button5.Text = "5"
Button6.Text = "6"
Button7.Text = "7"
Button8.Text = "8"
Button9.Text = "9"
Button10.Text = "0"
Button11.Text = "+"
Button12.Text = "-"
Button13.Text = "X"
Button14.Text = "/"
Button15.Text = "Calc"
Button16.Text = "About Me"
Button17.Text = "Clear"
'allows form to revcieve key events
Me.KeyPreview = True
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'create action when button 1 is clicked
'if state is 1 then previous calculation was solved, then clear textbox to allow for new input
If state = 1 Then
TextBox1.Text = ""
'insert 1 into textbox
Dim Int1 As Integer = 1
TextBox1.Text = TextBox1.Text & Int1
'return state of calculator to zero to designate that calculation has NOT been solved
state = 0
Else
'else insert 1 into textbox
Dim Int1 As Integer = 1
TextBox1.Text = TextBox1.Text & Int1
End If
End Sub
' the above function for each numbered button
Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
If state = 1 Then
TextBox1.Text = ""
Dim Int2 As Integer = 2
TextBox1.Text = TextBox1.Text & Int2
state = 0
Else
Dim Int2 As Integer = 2
TextBox1.Text = TextBox1.Text & Int2
End If
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
If state = 1 Then
TextBox1.Text = ""
Dim Int3 As Integer = 3
TextBox1.Text = TextBox1.Text & Int3
state = 0
Else
Dim Int3 As Integer = 3
TextBox1.Text = TextBox1.Text & Int3
End If
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
If state = 1 Then
TextBox1.Text = ""
Dim Int4 As Integer = 4
TextBox1.Text = TextBox1.Text & Int4
state = 0
Else
Dim Int4 As Integer = 4
TextBox1.Text = TextBox1.Text & Int4
End If
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
If state = 1 Then
TextBox1.Text = ""
Dim Int5 As Integer = 5
TextBox1.Text = TextBox1.Text & Int5
state = 0
Else
Dim Int5 As Integer = 5
TextBox1.Text = TextBox1.Text & Int5
End If
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
If state = 1 Then
TextBox1.Text = ""
Dim Int6 As Integer = 6
TextBox1.Text = TextBox1.Text & Int6
state = 0
Else
Dim Int6 As Integer = 6
TextBox1.Text = TextBox1.Text & Int6
End If
End Sub
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
If state = 1 Then
TextBox1.Text = ""
Dim Int7 As Integer = 7
TextBox1.Text = TextBox1.Text & Int7
state = 0
Else
Dim Int7 As Integer = 7
TextBox1.Text = TextBox1.Text & Int7
End If
End Sub
Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
If state = 1 Then
TextBox1.Text = ""
Dim Int8 As Integer = 8
TextBox1.Text = TextBox1.Text & Int8
state = 0
Else
Dim Int8 As Integer = 8
TextBox1.Text = TextBox1.Text & Int8
End If
End Sub
Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
If state = 1 Then
TextBox1.Text = ""
Dim Int9 As Integer = 9
TextBox1.Text = TextBox1.Text & Int9
state = 0
Else
Dim Int9 As Integer = 9
TextBox1.Text = TextBox1.Text & Int9
End If
End Sub
Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
If state = 1 Then
TextBox1.Text = ""
Dim Int0 As Integer = 0
TextBox1.Text = TextBox1.Text & Int0
state = 0
Else
Dim Int0 As Integer = 0
TextBox1.Text = TextBox1.Text & Int0
End If
End Sub
Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
'create an action for when addition button is clicked
Try
'when button is clicked dim sign and text in textbox
sign = "+"
one = TextBox1.Text
TextBox1.Text = ""
Catch ex As Exception
TextBox1.Text = "Error" ' if error occurs return error in textbox
state = 1 'if error occurs return state to 1 to allow for new calculation
End Try
End Sub
'repeat the above action for remainder of arithmic functions
Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click
Try
'when button is clicked dim sign and text in textbox
sign = "-"
one = TextBox1.Text
TextBox1.Text = ""
Catch ex As Exception
TextBox1.Text = "Error" ' if error occurs return error in textbox
state = 1 'if error occurs return state to 1 to allow for new calculation
End Try
End Sub
Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click
Try
sign = "*"
one = TextBox1.Text
TextBox1.Text = ""
Catch ex As Exception
TextBox1.Text = "Error" ' if error occurs return error in textbox
state = 1 'if error occurs return state to 1 to allow for new calculation
End Try
End Sub
Private Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click
Try
sign = "/"
one = TextBox1.Text
TextBox1.Text = ""
Catch ex As Exception
TextBox1.Text = "Error"
state = 1 'if error occurs return state to 1 to allow for new calculation
End Try
End Sub
Private Sub Button15_Click(sender As Object, e As EventArgs) Handles Button15.Click
'run functions based on sign stored during calculation
Try
two = TextBox1.Text
If sign = "+" Then
Calculator2.Math.add()
ElseIf sign = "-" Then
Calculator2.Math.minus()
ElseIf sign = "*" Then
Calculator2.Math.multiply()
ElseIf sign = "/" Then
Calculator2.Math.divide()
End If
'if user attempts to divide by zero return divide by zero error in textbox
If TextBox1.Text = "Infinity" Then
TextBox1.Text = "Divide by Zero Error"
state = 1 'if error occurs return state to 1 to allow for new calculation
End If
Catch ex As Exception
TextBox1.Text = "Error"
state = 1 'if error occurs return state to 1 to allow for new calculation
End Try
End Sub
Private Sub Button16_Click(sender As Object, e As EventArgs) Handles Button16.Click
'create message box that provides information about author
Dim msg = "Student Name: Emily Wong" & vbCrLf & "Student Number: 0692740" ' Define the message you want to see inside the message box.
Dim title = "About Me" ' Define a title for the message box.
Dim style = MsgBoxStyle.OkOnly ' make an ok button for the msg box
Dim response = MsgBox(msg, style, title)
End Sub
Private Sub Button17_Click(sender As Object, e As EventArgs) Handles Button17.Click
'create a clear button to clear textboxes when clicked and reset state of calculator
TextBox1.Text = ""
state = 0
End Sub
And this is my other class
Public Class Math
Inherits Form1
'create funtions for add,sub, multiply, and divide features
Sub add()
ans = one + two 'creates calculation of the entered numbers
TextBox1.Text = ans 'returns answer into the textbox
state = 1 'returns state to 1 to show that calculation has occured
End Sub
Sub minus()
ans = one - two
TextBox1.Text = ans
state = 1
End Sub
Sub multiply()
ans = one * two
TextBox1.Text = ans
state = 1
End Sub
Sub divide()
ans = one / two
TextBox1.Text = ans
state = 1
End Sub
End Class
state is a private variable in Form1. You can't access from code outside of Form1. Your Math class cannot reference state. Remove the calls to state from the Math class code. An outside class should not be changing the state of another object in anycase.
Try this instead:
Public Class accounting
Dim Operand1 As Double
Dim Operand2 As Double
Dim [Operator] As String
These are the button from 1 - 0
Private Sub Button6_Click_1(sender As Object, e As EventArgs) Handles Button9.Click, Button8.Click, Button7.Click, Button6.Click, Button5.Click, Button4.Click, Button19.Click, Button12.Click, Button11.Click, Button10.Click
txtans.Text = txtans.Text & sender.text
End Sub
This button is for period/point
Private Sub Button18_Click(sender As Object, e As EventArgs) Handles Button18.Click
If InStr(txtans.Text, ".") > 0 Then
Exit Sub
Else
txtans.Text = txtans.Text & "."
End If
End Sub
This button is for clear or "C" in calculator
Private Sub Button20_Click(sender As Object, e As EventArgs) Handles Button20.Click
txtans.Text = ""
End Sub
These are for add,subtract,divide, and multiply
Private Sub Buttonadd_Click(sender As Object, e As EventArgs) Handles Button13.Click
Operand1 = Val(txtans.Text)
txtans.Text = ""
txtans.Focus()
[Operator] = "+"
End Sub
Private Sub Buttondivide_Click(sender As Object, e As EventArgs) Handles Button15.Click
Operand1 = Val(txtans.Text)
txtans.Text = ""
txtans.Focus()
[Operator] = "-"
End Sub
Private Sub Buttonsubtract_Click(sender As Object, e As EventArgs) Handles Button16.Click
Operand1 = Val(txtans.Text)
txtans.Text = ""
txtans.Focus()
[Operator] = "*"
End Sub
Private Sub Buttonmultiply_Click(sender As Object, e As EventArgs) Handles Button14.Click
Operand1 = Val(txtans.Text)
txtans.Text = ""
txtans.Focus()
[Operator] = "/"
End Sub
This button is for "=" sign
Private Sub Buttoneequal_Click(sender As Object, e As EventArgs) Handles Button17.Click
Dim Result As Double
Operand2 = Val(txtans.Text)
'If [Operator] = "+" Then
' Result = Operand1 + Operand2
'ElseIf [Operator] = "-" Then
' Result = Operand1 - Operand2
'ElseIf [Operator] = "/" Then
' Result = Operand1 / Operand2
'ElseIf [Operator] = "*" Then
' Result = Operand1 * Operand2
'End If
Select Case [Operator]
Case "+"
Result = Operand1 + Operand2
txtans.Text = Result.ToString("#,###.00")
Case "-"
Result = Operand1 - Operand2
txtans.Text = Result.ToString("#,###.00")
Case "/"
Result = Operand1 / Operand2
txtans.Text = Result.ToString("#,###.00")
Case "*"
Result = Operand1 * Operand2
txtans.Text = Result.ToString("#,###.00")
End Select
txtans.Text = Result.ToString("#,###.00")
End Sub
This button is for backspace effect.
Private Sub Buttondel_Click(sender As Object, e As EventArgs) Handles Button21.Click
If txtans.Text < " " Then
txtans.Text = Mid(txtans.Text, 1, Len(txtans.Text) - 1 + 1)
Else
txtans.Text = Mid(txtans.Text, 1, Len(txtans.Text) - 1)
End If
End Sub
Note that "txtans.text" is the textbox where the user inputs and where the output shows.
I am having an issue in my script with things running sequentially. I have an initial script to decompile an swf. A second that searches for one string in one of the decompiled files and a third for recompiling into a new swf.
How can I make each process wait until it completes before the next is started?
I am also having trouble with making the second script actually work. It would be nice if I could display something about what it replaced after it finished.
Here is my script so far:
Imports System.Net
Public Class Form3
Private Sub Button7_Click(sender As System.Object, e As System.EventArgs) Handles Button7.Click
If TextBox4.Text = "" Then
MessageBox.Show("Please select a directory")
Else
Dim fd As OpenFileDialog = New Ope
nFileDialog()
Dim strFileName As String
fd.Title = "Open File Dialog"
fd.InitialDirectory = TextBox1.Text
fd.Filter = "All files (*.*)|*.*|All files (*.*)|*.*"
fd.FilterIndex = 2
fd.RestoreDirectory = True
If fd.ShowDialog() = DialogResult.OK Then
strFileName = fd.FileName
If InStr(strFileName, ".swf") <> 0 Then
TextBox2.Text = strFileName
Else
MessageBox.Show("You have to pick a .swf silly...")
End If
End If
End If
End Sub
Private Sub Button8_Click(sender As System.Object, e As System.EventArgs) Handles Button8.Click
Me.Close()
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim Folder = TextBox4.Text & "\HEXED"
If TextBox2.Text = "" Then
MessageBox.Show("You have to pick a .swf silly...")
Else
If My.Computer.FileSystem.DirectoryExists(Folder) Then
My.Computer.FileSystem.DeleteDirectory(Folder, FileIO.DeleteDirectoryOption.DeleteAllContents)
End If
My.Computer.FileSystem.CopyDirectory("C:\Users\Matt\Documents\My_Games\ROTMG\ShadyGamer\WindowsApplication1\WindowsApplication1\RABCDasm", Folder)
My.Computer.FileSystem.CopyFile(TextBox2.Text, Folder & "\client.swf", True)
Dim FILE_NAME As String = Folder & "\decompile.bat"
Dim i As Integer
Dim aryText(4) As String
aryText(0) = "cd " & Folder
aryText(1) = "swfdecompress client.swf"
aryText(2) = "abcexport client.swf"
aryText(3) = "rabcdasm client-1.abc"
Dim objWriter As New System.IO.StreamWriter(FILE_NAME, False)
For i = 0 To 3
objWriter.WriteLine(aryText(i))
Next
objWriter.Close()
Dim psi As New ProcessStartInfo(Folder & "\decompile.bat")
psi.RedirectStandardError = True
psi.RedirectStandardOutput = True
psi.CreateNoWindow = False
psi.WindowStyle = ProcessWindowStyle.Hidden
psi.UseShellExecute = False
Dim decompile As New Process
Process.Start(psi)
MessageBox.Show("Click Step 2")
Button1.Visible = False
Button3.Visible = True
End If
End Sub
Private Sub TextBox4_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox4.TextChanged
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
Dim MyFolderBrowser As New System.Windows.Forms.FolderBrowserDialog
MyFolderBrowser.Description = "Select the Folder"
MyFolderBrowser.ShowNewFolderButton = False
Dim dlgResult As DialogResult = MyFolderBrowser.ShowDialog()
If dlgResult = Windows.Forms.DialogResult.OK Then
TextBox4.Text = MyFolderBrowser.SelectedPath
End If
End Sub
Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
Dim Folder = TextBox4.Text & "\HEXED"
Const quote As String = """"
Dim MyFile As String = Folder & "\client-1\com\company\assembleegameclient\parameters\Parameters.class.asasm"
Replace(MyFile, quote & TextBox1.Text & quote, quote & TextBox3.Text & quote)
MessageBox.Show("Click Step 3")
Button3.Visible = False
Button4.Visible = True
End Sub
Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click
Dim Folder = TextBox4.Text & "\HEXED"
Dim FILE_NAME2 As String = Folder & "\recompile.bat"
Dim j As Integer
Dim aryText2(4) As String
aryText2(0) = "cd " & Folder
aryText2(1) = "rabcasm client-1\client-1.main.asasm"
aryText2(2) = "abcreplace client.swf 1 client-1\client-1.main.abc"
Dim objWriter2 As New System.IO.StreamWriter(FILE_NAME2, False)
For j = 0 To 2
objWriter2.WriteLine(aryText2(j))
Next
objWriter2.Close()
Dim ps As New ProcessStartInfo(Folder & "\recompile.bat")
ps.RedirectStandardError = True
ps.RedirectStandardOutput = True
ps.CreateNoWindow = False
ps.WindowStyle = ProcessWindowStyle.Hidden
ps.UseShellExecute = False
Dim recompile As Process = Process.Start(ps)
My.Computer.FileSystem.CopyFile(Folder & "\client.swf", TextBox4.Text & "\hexed.swf", True)
End Sub
End Class
You can use process.WaitForExit() - msdn here - http://msdn.microsoft.com/en-us/library/system.diagnostics.process.waitforexit.aspx
Update
You'll need to change the way you start the process to use this:
Dim ps As New System.Diagnostics.Process()
Dim psi As New System.Diagnostics.ProcessStartInfo(folder & "\decompile.bat")
psi.RedirectStandardError = True
psi.RedirectStandardOutput = True
psi.CreateNoWindow = False
psi.WindowStyle = ProcessWindowStyle.Hidden
psi.UseShellExecute = False
ps.StartInfo = psi
ps.Start()
ps.WaitForExit()
I compiled the following little application only I want all the textpoxes cleard when the tabs areswitched by the user how can this be achieved?
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim FILE_NAME As String = "C:\test.pgp"
If System.IO.File.Exists(FILE_NAME) = True Then
Dim objWriter As New System.IO.StreamWriter(FILE_NAME, True)
objWriter.WriteLine((TextBox2.Text) + "," + " " + "*" + (TextBox1.Text))
objWriter.Close()
MsgBox("The acad.pgp file was successfully appended…")
Else
MsgBox("File missing reinstall or contact vendor…")
End If
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim FILE_NAME As String = "C:\test.pgp"
If System.IO.File.Exists(FILE_NAME) = True Then
Dim objWriter As New System.IO.StreamWriter(FILE_NAME, True)
objWriter.WriteLine((TextBox3.Text) + "," + " " + "START " + (TextBox4.Text) + ", 1,,")
objWriter.Close()
MsgBox("The acad.pgp file was successfully appended…")
Else
MsgBox("File missing reinstall or contact vendor…")
End If
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim FILE_NAME As String = "C:\test.pgp"
If System.IO.File.Exists(FILE_NAME) = True Then
Dim objWriter As New System.IO.StreamWriter(FILE_NAME, True)
objWriter.WriteLine((TextBox5.Text) + "," + " " + "START " + (TextBox6.Text) + ", 1,,")
objWriter.Close()
MsgBox("The acad.pgp file was successfully appended…")
Else
MsgBox("File missing reinstall or contact vendor…")
End If
End Class
Public Sub ClearTextBoxes(frmClearMe As Form)
Dim txt As Control
For Each txt In frmClearMe
If TypeOf txt Is TextBox Then txt.Text = ""
Next
End Sub