|
That's called a "service application". Windows starts services before users get a chance to log in.
|
|
|
|
|
I can't make my listbox height same as my textbox in a form, how do I resize the listbox as I wanted.
|
|
|
|
|
Try setting the Listbox's IntegralHeight property to False
|
|
|
|
|
I got 'em right now, thanks buddy, you are a big help
|
|
|
|
|
I am completely new to vb programming or programming in general! I am a 30 year old want to be programmer but it is so hard for me to understand any languages at all. I tried visual basic many years ago and never got the hang of it at all. This is my first serious attempt at any programming. Well on with my question. I need to make a program that will
1. check to see if device is connected
2. install an .apk file
3. install another .apk file
4. push a folder with preinstalled apps into said directory
I am trying to make a program for my phone. I will be using adb and adb commands. I would like to distribute this with my friends but when I run the program on there computer it says directory not found, then it shows my directory on their computer. Please help so confused
|
|
|
|
|
Member 12079859 wrote: when I run the program on there computer it says directory not found
Can you provide us the line of code that threw this exception, as well as how the variable(s) it is using are declared and assigned?
I never finish anyth
|
|
|
|
|
Imports System.IO
Imports System.Threading
Imports System.Windows.Forms.DialogResult
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
If Not Directory.Exists("ADB") Then
Directory.CreateDirectory("ADB")
Else
If Not File.Exists("ADB\adb.exe") Then
File.WriteAllBytes("ADB\adb.exe", My.Resources.adb)
End If
If Not File.Exists("ADB\AdbWinApi.dll") Then
File.WriteAllBytes("ADB\AdbWinApi.dll", My.Resources.AdbWinApi)
End If
If Not File.Exists("ADB\AdbWinUsbApi.dll") Then
File.WriteAllBytes("ADB\AdbWinUsbApi.dll", My.Resources.AdbWinUsbApi)
End If
If Not File.Exists("ADB\fastboot.exe") Then
File.WriteAllBytes("ADB\fastboot.exe", My.Resources.fastboot)
End If
End If
If Not Directory.Exists("Addon") Then
Directory.CreateDirectory("Addon")
Else
If Not File.Exists("Addon\Firestarter.apk") Then
File.WriteAllBytes("Addon\Firestarter.exe", My.Resources.Firestarter)
End If
End If
End Sub
Function adb(ByVal Arguments As String) As String
Try
Dim My_Process As New Process()
Dim My_Process_Info As New ProcessStartInfo()
My_Process_Info.FileName = "cmd.exe" ' Process filename
My_Process_Info.Arguments = Arguments ' Process arguments
My_Process_Info.WorkingDirectory = "/c"
My_Process_Info.CreateNoWindow = True
My_Process_Info.UseShellExecute = False
My_Process_Info.RedirectStandardOutput = True ' Redirect (1) Output
My_Process_Info.RedirectStandardError = True ' Redirect non (1) Output
My_Process.EnableRaisingEvents = True
My_Process.StartInfo = My_Process_Info
My_Process.Start() ' Run the process NOW
Dim Process_ErrorOutput As String = My_Process.StandardOutput.ReadToEnd() ' Stores the Error Output (If any)
Dim Process_StandardOutput As String = My_Process.StandardOutput.ReadToEnd() ' Stores the Standard Output (If any)
' Return output by priority
If Process_ErrorOutput IsNot Nothing Then Return Process_ErrorOutput ' Returns the ErrorOutput (if any)
If Process_StandardOutput IsNot Nothing Then Return Process_StandardOutput ' Returns the StandardOutput (if any)
Catch ex As Exception
Return ex.Message
End Try
Return "OK"
End Function
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
MsgBox(adb("/c adb devices"))
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim sr As New IO.FileStream("", IO.FileMode.Open)
Dim sw As New IO.FileStream("[copyto]", IO.FileMode.Create)
Dim len As Long = sr.Length - 1
Dim buffer(1024) As Byte
Dim bytesread As Integer
While sr.Position < len
bytesread = (sr.Read(buffer, 0, 1024))
sw.Write(buffer, 0, bytesread)
ProgressBar1.Value = CInt(sr.Position / len * 100)
Application.DoEvents()
End While
sw.Flush()
sw.Close()
sr.Close()
MsgBox(adb("/c adb install Firestarter.apk"))
End Sub
I'm embarrassed because this is about 4 guys just who have no idea and just winging code together. Only one guy has some and i mean very little experience. Any suggestions help. Trying to figure out how to allow other computer or phone to find the program or have it installed or uploaded to their device if that makes any sense. Thank you so much
modified 23-Oct-15 8:10am.
|
|
|
|
|
When you write
If Not Directory.Exists("someDirectoryName") Then
(and ditto for File.Exists ), then you need to pass the full path, not the relative one. You can use
If Not Directory.Exists(Application.StartUpPath & "\someDirectoryName") Then
|
|
|
|
|
Message Closed
modified 16-Oct-15 5:06am.
|
|
|
|
|
A question so good you thought it needed asking three times?
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
Imports System.Data.OleDb
Public Class Inquiry_Form
Dim provider As String
Dim dataFile As String
Dim connstring As String
Dim myConnection As OleDbConnection = New OleDbConnection
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
provider = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
dataFile = "Database3.mdb"
connstring = provider & dataFile
myConnection.ConnectionString = connstring
myConnection.Open()
Dim str As String
str = "INSERT INTO Inquiry_Form([Date],[RefNo],[NameP],[Address],[Age],[PhoneNo],[MobileNo],[EmailAd],[ReferralQuestion],[Type_of_Unit],[Date_of_Purchase],[Purpose_of_Purchase],[Monthly_Income],[RName],[RAddress],[RMobileNo],[R2Name],[R2Address],[RMobileNo],[R2Name],[R2Address],[R2MobileNo],[AgentsName]) Values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection)
cmd.Parameters.Add(New OleDbParameter("Date", CType(TextBox1.Text, String)))
cmd.Parameters.Add(New OleDbParameter("RefNo", CType(TextBox2.Text, String)))
cmd.Parameters.Add(New OleDbParameter("NameP", CType(TextBox3.Text, String)))
cmd.Parameters.Add(New OleDbParameter("Address", CType(TextBox4.Text, String)))
cmd.Parameters.Add(New OleDbParameter("Age", CType(TextBox5.Text, String)))
cmd.Parameters.Add(New OleDbParameter("PhoneNo", CType(TextBox6.Text, String)))
cmd.Parameters.Add(New OleDbParameter("MobileNo", CType(TextBox8.Text, String)))
cmd.Parameters.Add(New OleDbParameter("EmailAd", CType(TextBox7.Text, String)))
cmd.Parameters.Add(New OleDbParameter("ReferralQuestion", CType(ComboBox1.Text, String)))
cmd.Parameters.Add(New OleDbParameter("Type_of_Unit", CType(ComboBox2.Text, String)))
cmd.Parameters.Add(New OleDbParameter("Date_of_Purchase", CType(ComboBox3.Text, String)))
cmd.Parameters.Add(New OleDbParameter("Purpose_of_Purchase", CType(ComboBox4.Text, String)))
cmd.Parameters.Add(New OleDbParameter("Monthly_Income", CType(ComboBox5.Text, String)))
cmd.Parameters.Add(New OleDbParameter("RName", CType(TextBox10.Text, String)))
cmd.Parameters.Add(New OleDbParameter("RAddress", CType(TextBox11.Text, String)))
cmd.Parameters.Add(New OleDbParameter("RMobileNo", CType(TextBox15.Text, String)))
cmd.Parameters.Add(New OleDbParameter("R2Name", CType(TextBox12.Text, String)))
cmd.Parameters.Add(New OleDbParameter("R2Address", CType(TextBox13.Text, String)))
cmd.Parameters.Add(New OleDbParameter("R2MobileNo", CType(TextBox14.Text, String)))
cmd.Parameters.Add(New OleDbParameter("AgentsName", CType(TextBox16.Text, String)))
Try
cmd.ExecuteNonQuery()
cmd.Dispose()
myConnection.Close()
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
TextBox6.Clear()
TextBox8.Clear()
TextBox7.Clear()
TextBox10.Clear()
TextBox11.Clear()
TextBox15.Clear()
TextBox12.Clear()
TextBox13.Clear()
TextBox14.Clear()
TextBox16.Clear()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.Close()
Menu_Page.Show()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs)
Inquiry_FormBindingSource1.AddNew()
End Sub
Private Sub Inquiry_Form_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'Database3DataSet.Inquiry_Form' table. You can move, or remove it, as needed.
Me.Inquiry_FormTableAdapter.Fill(Me.Database3DataSet.Inquiry_Form)
End Sub
End Class
|
|
|
|
|
A likey explanation is that you haven't closed the connection in some other part of your code.
|
|
|
|
|
That is why it is recommended to create a connection in the method where you need it, and to wrap it in a using-block to ensure disposing. It might sound expensive to create a new connection-object, but it is not. Hunting for these kinds of bugs is however.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
You attempt to execute an INSERT statement which specifies 23 columns, but only inserts 20 values.
That throws the "Number of query values and destination fields are not the same" exception.
Your code then fails to close the connection, so the next time you click the button, you get the "Not allowed to change the 'ConnectionString' property..." exception.
As the others have said, create your connection object inside the method, and wrap it in a Using block[^] to ensure that it is always disposed of properly.
Make sure your INSERT statement has the same number of parameter placeholders in the VALUES part as the number of columns in the INSERT INTO part.
There's no need to convert the Text property to a string, as it's already a string.
You can simplify adding the parameters by using the AddWithValue method.
You should avoid catching the general Exception type. Only catch the exceptions that you want to handle. In this case, System.Data.Common.DbException is the only one you want to catch.
Const ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Database3.mdb"
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Const CommandText As String = "INSERT INTO Inquiry_Form([Date], [RefNo], [NameP], [Address], [Age], [PhoneNo], [MobileNo], [EmailAd], [ReferralQuestion], [Type_of_Unit], [Date_of_Purchase], [Purpose_of_Purchase], [Monthly_Income], [RName], [RAddress], [RMobileNo], [R2Name], [R2Address], [RMobileNo], [R2Name], [R2Address], [R2MobileNo], [AgentsName]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
Using connection As New OleDbConnection(ConnectionString)
Using cmd As New OleDbCommand(CommandText, connection)
cmd.Parameters.AddWithValue("Date", TextBox1.Text)
cmd.Parameters.AddWithValue("RefNo", TextBox2.Text)
cmd.Parameters.AddWithValue("NameP", TextBox3.Text)
cmd.Parameters.AddWithValue("Address", TextBox4.Text)
cmd.Parameters.AddWithValue("Age", TextBox5.Text)
cmd.Parameters.AddWithValue("PhoneNo", TextBox6.Text)
cmd.Parameters.AddWithValue("MobileNo", TextBox8.Text)
cmd.Parameters.AddWithValue("EmailAd", TextBox7.Text)
cmd.Parameters.AddWithValue("ReferralQuestion", ComboBox1.Text)
cmd.Parameters.AddWithValue("Type_of_Unit", ComboBox2.Text)
cmd.Parameters.AddWithValue("Date_of_Purchase", ComboBox3.Text)
cmd.Parameters.AddWithValue("Purpose_of_Purchase", ComboBox4.Text)
cmd.Parameters.AddWithValue("Monthly_Income", ComboBox5.Text)
cmd.Parameters.AddWithValue("RName", TextBox10.Text)
cmd.Parameters.AddWithValue("RAddress", TextBox11.Text)
cmd.Parameters.AddWithValue("RMobileNo", TextBox15.Text)
cmd.Parameters.AddWithValue("R2Name", TextBox12.Text)
cmd.Parameters.AddWithValue("R2Address", TextBox13.Text)
cmd.Parameters.AddWithValue("R2MobileNo", TextBox14.Text)
cmd.Parameters.AddWithValue("AgentsName", TextBox16.Text)
Try
connection.Open()
cmd.ExecuteNonQuery()
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
TextBox6.Clear()
TextBox8.Clear()
TextBox7.Clear()
TextBox10.Clear()
TextBox11.Clear()
TextBox15.Clear()
TextBox12.Clear()
TextBox13.Clear()
TextBox14.Clear()
TextBox16.Clear()
Catch ex As System.Data.Common.DbException
MsgBox(ex.Message)
End Try
End Using
End Sub
You should also give your controls meaningful names, rather than accepting the default names created by the designer. You might remember that TextBox11 is the "RAddress" now, but when you come back to this code in a few months, you'll be cursing yourself for leaving the controls with the default names!
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
hi
you have wrong in fields names
[R2Name],[R2Address],[RMobileNo],[R2Name],[R2Address],[R2MobileNo]
it is repeated so you have error
|
|
|
|
|
Can anybody help me create VB Script that I can use to gather the NIC Card Configuration for a list of Servers and store the information into an Excel Spread Sheet.
The Servers will have multiple Network Cards in use and I require the IP, Subnet and Gateway for each one in use.
Any help greatly appreciated!!
|
|
|
|
|
And? What part of this are you having a problem with?
|
|
|
|
|
pls i need the procedure on how to read a 3D stl file in vb 2010 ,i have already loaded the Glcontrol on my window application form .am new to vb.net pls i need help .thank you all
|
|
|
|
|
You're asking about the functionality of a 3rd party library. The best for support on it and how to use is the vendor for the library, here[^].
|
|
|
|
|
In an existing vb.net 2010 desktop application, I would need to have 2 users share the same computer. Both users will run the same desktop application but have access to different files and folders on the network share. Each person will have their own unqiue config file to show what files they have access to.
Based upon what I have said, I have the following questions to ask:
1. Will I need separate installs of the application on the same computer? Part of the install process includes placing the app.config file in the correct location. If so, can you tell me what I need to do for the separate installs?
2. If I do not need separate installs, what should I do about the separate app.config files? Each person's config file will point to files they directly have access to. I do not want each person to access the other person's config file.
modified 13-Oct-15 13:11pm.
|
|
|
|
|
dcof wrote: Will I need separate installs of the application on the same computer? No, you can get the windows user name and then use that to allow/disallow certain access.
dcof wrote: Each person's config file will point to files they directly have access to. I do not want each person to access the other person's config file. If they are admins on the machine then they can get access to it. Otherwise, if they are not, then you can use the user's app_data folder or something like that. But, it sounds like you may want to encrypt the config file or use a sql database to store what they can access.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
The files are on a network share. Thus can you tell me how I can restrict access by user on a network share?
|
|
|
|
|
dcof wrote: how I can restrict access by user on a network share Not sure what you mean exactly, but you can just right-click folders and set permissions.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Thanks this solves my issue!
|
|
|
|
|
Good to hear.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|