Those controls has been removed.
Instead you can use the standard ListBox control, or the OpenFileDialog/SaveFileDialog controls.
Although, it is possible to add VB6 controls to your project.
Just follow this article.
Well.
Since you're using ByRef for the arguments, then line 12 can be changed into simply this: "cslsMethods.Method(var1, var2)".
Ie, remove the "Dim value As Object = " part.
Does this solution work for you?
Ok, then.
If the splash screen is supposed to be the very first thing to load, perhaps you could put those codes in that form.
And here's another tip.
Load up the Task Manager and select the services tab.
Than fire up your application and keep an eye on the task manager.
If you applications exe shows up in the list, then you know for sure that it's actually being started.
If not, you should examine the EventLog to see if Windows has reported any failures.
Here is the modified code.
Try
'Set up connection string
Dim cnString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Application.StartupPath & "\Payment.mdb;"
Dim sqlQRY As String = "SELECT COUNT(*) AS numRows FROM CustomerInformation WHERE CustomerName = '" & TextBox1.Text & "'"
Dim queryResult As Integer
'Create connection
Dim conn As OleDbConnection = New OleDbConnection(cnString)
' Open connection
conn.Open()
' Query the database
Dim com As New OleDbCommand(sqlQRY, conn)
queryResult = com.ExecuteScalar()
' Close connection
conn.Close()
If queryResult > 0 Then
MessageBox.Show("Already Exists!", "ALI ENTERPRISES", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
Catch ex As OleDbException
MessageBox.Show("Customer Not found" + ex.Message)
End Try
Nah. That's not the problem.
Although you should seriously consider buying it, regardless.
Did you add that label to the form, and the codesnippet?
Did you get any numbers in there?
Just put the code in the keypress event.
You can do that in two ways.
1) First perform a normal "SELECT COUNT(*) AS numrows" query on the database, where the WHERE clause contains those fields that makes the record unique.
And if the query returns a "numrows > 0" then the record exists.
Dim con As New SqlConnection("connectionstring")
Dim com As SqlCommand = Nothing
Dim queryResult As Integer
con.Open()
com = New SqlCommand("SELECT COUNT(*) AS numRows FROM table WHERE ...", con)
queryResult = com.ExecuteScalar()
con.Close()
If queryResult = 0 Then
con.Open()
com = New SqlCommand("INSERT INTO table (field1, field2, field3) VALUES (value1, value2, value3)", con)
com.ExecuteNonQuery()
con.Close()
Else
MessageBox.Show("Record already exists", "Existing record", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
2) Using the INSERT query I provided the SqlCommand.ExecuteNonQuery method will return the number of affected rows.
If the INSERT failed, then the return is 0, and if the INSERT succeded then the return is 1.
Dim con As New SqlConnection("connectionstring")
Dim com As SqlCommand = Nothing
Dim queryResult As Integer
con.Open
com = New SqlCommand("INSERT QUERY", con)
queryResult = com.ExecuteNonQuery
con.Close()
If queryResult = 0 Then
MessageBox.Show("Record already exists", "Existing record", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
It depends.
If you're talking about storing a new record into a database, then that could be accomplished by a simple SQL query.
INSERT INTO table (field1, field2, field3) VALUES (value1, value2, value3) WHERE NOT EXISTS (SELECT field1, field2, field3 FROM table WHERE name_field = 'name')
If you're talking about a datagrid, all you have to do is loop through the rows and compare the cells with what you want to store.
First you need to check if the buffer contains any data.
Put a label on the form and add this code between the read and the write.
Label1.Text = byteFile.Length()
The second thing to check see is if sharing is activated on the client computer, and thus if the share c$ exists.
Type the command NET SHARE in the command prompt.
Visual Studio 2010 does not provide the necessary tools for upgrading a VB6 project.
In order to do that, you must first upgrade the project in a previous version of Visual Studio, and then upgrade THAT project with VS2010.
Check this article.
And the only way to upgrade your VB6 project to .NET, without using the wizard, is by manually recreating the entire project from scratch.
Add a regular button to your form.
Then set the property FlatStyle to Flat, go to BackgroundImage and select the image you created and finally set the property BackgroundImageLayout to Stretch.
That will make it look like you have created your own button.
Just make sure that the background color of your image is transparent.
Your code would work perfectly if you manually populated the DataGridView.
But because the grid is databound, any changes to the grid layout, ie a new column, will result in an error because that column is not part of the original database table.
The error occurs because the change in the datagrid will trigger an event in the grid to perform a change in the underlying datatable.
Now, if you add a boolean column to the datatable before binding it to the datagrid, then the checkbox column will be shown, and any changes to it will not result in error.
Try
cmd.CommandText = "SELECT *" & _
"FROM oracle database
Dim da As New OracleDataAdapter(cmd)
Dim DMdt As New DataTable
da.Fill(DMdt)
If DMdt.Rows.Count > 0 Then
DMDt.Columns.Add(New DataColumn("Part", GetType(Boolean)))
Me.DataGridView1.DataSource = DMdt
'filter the datatable
da.Dispose()
I would suggest that you add a few pieces of code for Release version debugging.
In the code for the primary form, add a StreamWriter and put a bunch of writer.WriteLine("Now I'm doing this thing") lines in strategic places.
When the application launches, those lines will be written to a textfile defined in the StreamWriter. And then you can examine that file to see what's going on.
Good luck! :)
It is not possible to assign a method to a variable like that.
But you can create a class that holds all those methods, where you tell the constructor which method to execute.
Like this:
Public Class Methods
Private strMethodName As String
Private objVar1 As Object
Private objVar2 As Object
Public Sub New(NameOfMethod As String)
Me.strMethodName = NameOfMethod
End Sub
Public Function Method(Var1 As Object, Var2 As Object) As Object
objVar1 = Var1
objVar2 = Var2
Select Case strMethodName
Case "method1":
Return method_1()
Case "method2":
Return method_2()
'And so on
Else
Return method_n()
End Select
End Function
Private Function method_1() As Object
'Do something with var1 and var2
Return result
End Function
Private Function method_2() As Object
'Do something else with var1 and var2
Return result
End Function
Private Function method_n() As Object
'Do something else with var1 and var2
Return result
End Function
End Class
Then do this in your code:
'This is your code
Dim clsMethods As Methods
If radiobutton1.checked = true then
clsMethods = New Methods("method1")
ElseIf radiobutton2.checked = true then
clsMethods = New Methods("method2")
Else
clsMethods = New Methods("method3")
End If
For i = 0 To 1000
Dim value As Object = clsMethods.Method(var1, var2)
'Do something with the value
Next
Ok. Then do some experimenting. :)
This may look weird, but it might just work.
Let's check to see if the buffer gets filled.
Protected Sub btndownload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btndownload.Click
Dim i As Integer
Dim TxtLocalSysName As String = Request.UserHostName
Dim readStream As FileStream
Dim writeStream As FileStream
Try
For i = 0 To lstdownload.Items.Count - 1
Dim filePath As String = Me.Label5.Text + "\" + lstdownload.Items(i).Text
Dim targetFile As System.IO.FileInfo = New System.IO.FileInfo(filePath)
readStream = New FileStream(filePath, FileMode.Open)
Dim length As Integer = Convert.ToInt32(readStream.Length)
'This is the buffer.
Dim byteFile() As Byte = New Byte(length) {}
readStream.Read(byteFile, 0, length)
readStream.Close()
Dim localPath As String = "\\" & TxtLocalSysName & "\c$\downloads"
If Not Directory.Exists(localPath) Then
Directory.CreateDirectory(localPath)
End If
writeStream = New FileStream(localPath & "\" & targetFile.Name, FileMode.Create)
writeStream.Write(byteFile, 0, length)
writeStream.Close()
Next i
Catch ex As Exception
Console.WriteLine("The process failed: {0}", ex.ToString())
Finally
readStream.Close()
readStream.Dispose()
writeStream.Close()
writeStream.Dispose()
End Try
End Sub
Welcome to the world of .NET, friend. :)
In my personal oppinion, although COM has it's uses, it has become a thing of the past.
And unless you absolutaly need to access certain specialized code and functionality created in COM objects, you'll find almost everything you need in existing .NET objects.
And to answer some of your questions.
Yes, COM still exists and you pretty much access exposed code the same way as you did with VB6.
That said, I found a link to a tutoral about COM interoperating here.
Are there any errors being thrown?
A while ago I was facing a similar situation, but in reverse.
I added a feature for a web-portal where users could upload files to the server, and those files needed to be moved to a fileserver located behind two firewalls and the DMZ.
This is my solution.
After the file has been uploaded to the server, I immediately convert the file into a byte array and send it to a webservice, which in turn have limited access to a single predefined folder on the fileserver.
So here's what I suggest.
Create a webservice with a method that stream reads the desired file/s into a byte array, send the array, and then reconstruct the byte array into a file on the target system.
It may seem like a round-about way of doing it, but it's actually quite fast.
The reason for why it's not working for you might be as simple as a credential mismatch. Ie, the IIS_USR or ASPNET user on the server may not have read/copy rights.
Yes. Well.
Having 100 pictureboxes on the form and moving them at the same time in a timer event, will slow things down.
Based on the name of your class BulletArray I'm gonna assume that the pictureboxes contain a picture of a bullet, and that moving the picturebox somehow will simulate that the bullet is moving.
You should instead look into using GDI, and use the Paint method for a panel to move your bullet.
This is just a sample of what can be done, practically flicker free.
The sample is based on this article.
Glad to be of help. :)
Please mark this thread as solved.
Glad to be of help. :)
Please mark this thread as solved.
Yes. I got that.
What is it that you want to go faster??
Do you want something to move?
Do you want to add pictureboxes faster?
What?
Well.
If you already have a MySQL server somewhere, then the MySQL connector is enough for the connection.
The method SetAdded() is a part of the DataRow object, which comes standard with .NET.
Just copy the code in the snippet as is.
Here's how to set the primary key for a table in SQL server.
Start SQL Server Management Studio Express, and logon to the server.
Browse to the database and expand the tables folder.
Right-click on the table in question and select Modify.
In this view, right-click on the small left-hand side row-header, for the field that needs to be a Primary Key, and select "Set Primary Key". That's it.
Save, close and exit SQL Server Management Studio Express.
Unfortunatily, the standard combobox does not support true multiple columns. You have to go custom for that.
There is one solution that I found a while back ago, when I was researching readonly comboboxes.
It involves one combobox and one textbox.
Put the textbox on top of the combobox, set the width to cover all of the combobox except the dropdown-arrow, and set it's visibility to false.
Private Sub ComboBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.Click
TextBox1.Visible = False
End Sub
Privte Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If ComboBox1.SelectedIndex > -1 Then
TextBox1.Visible = True
TextBox1.Text = ComboBox1.SelectedItem.ToString().SubString(0, ComboBox1.SelectedItem.ToString().IndexOf("<delimiter>"))
End If
End Sub
This works perfectly for me.
See if it helps: http://zoloft.shacknet.nu:8080/~oxiegen/DaniWeb/PrintTest.zip
Replace your codesnippet with this:
PageSetupDialog1.Document = PrintDocument1
If PageSetupDialog1.ShowDialog = DialogResult.OK Then
PrintForm1.PrinterSettings.DefaultPageSettings.Margins = PageSetupDialog1.PageSettings.Margins
PrintForm1.Print()
End If
What are you trying to do?
My apologies, beyond that I cannot help you.
I have no idea of how to accomplish that.
If you need to print a part of a form, perhaps you should have a look into the PrintForm component in Visual Basic Power Packs 3.0.
Beyond that, I would appreciate it if you would mark this thread as solved.
According to this paper, a printer (of any kind) does not automatically support printing of barcodes by the use of a font.
It seems like it would be less of a hazzle to go the bitmap way, and print an image instead of a text.
This is what you need, it's a multi-column combobox.
http://www.vbaccelerator.com/home/net/code/controls/ListBox_and_ComboBox/Icon_ComboBox/article.asp
And for your problem with unselecting a selected item, use combobox1.SelectedIndex = -1
.
Oh, no.
On the sql server, create a new user with a password, and give this user read-write access to the database in question.
Then, use this user to logon to the server from your application.
Just type in the username and password in your connection string.
I'm assuming, of course, that you're using a stand-alone SQL Server 2005.
It would be helpful with the complete error message.
Also, I just tested the code you posted.
And I experienced no problems what so ever with it.
The text in all the textboxes printed out just find, one line after another, without the actual textboxes.
Is this the code you posted in the thread "Print Problem"?
And are the textboxes printed after the text?
I don't understand what you mean by that.
Does the text lines have borders or something?
What happens during debugging?
Does the code step into the For...Next iteration?
What's the size of linesPerPage and yPosition?
Does the code reach the line e.Graphics.DrawString(...)
?
Depending on what error message you get, my first guess is that you're not using
dedicated login credentials for the SQL server.
What I mean is, you are probably using Windows Authentication instead of a specific username and password, and that your client system does not have access to the server.
Well, first of all you'll need the Mysql Connector/NET.
You will find it here.
Second, everything you've read so far about connecting to an MS SQL server, either here or elsewhere, you can apply when dealing with MySQL.
All you have to do is replace any reference to SqlConnection, SqlCommand and so on, with MySqlConnection, MySqlCommand and so on.
Also, the connectionstring is different: check this site.
Have you tried to google it?
Keywords: developer certification
But to get you started on your quest: http://certification.about.com/cs/beginner/a/progcerts.htm
Although this should have been posted in the ASP.NET forum.
Here's the solution:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Me.IsPostBack = False Then
chklst.Items.Add("Gold")
chklst.Items.Add("Red")
chklst.Items.Add("Blue")
chklst.Items.Add("Yellow")
chklst.Items.Add("Black")
chklst.Items.Add("Orange")
End If
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
Select Case chklst.SelectedIndex
Case 0:
Label1.Text = chklst.SelectedItem
Case 1:
Label2.Text = chklst.SelectedItem
Case 2:
Label3.Text = chklst.SelectedItem
Case 3:
Label4.Text = chklst.SelectedItem
Case 4:
Label5.Text = chklst.SelectedItem
Case 5:
Label6.Text = chklst.SelectedItem
Case Else
Label1.Text = ""
Label2.Text = ""
Label3.Text = ""
Label4.Text = ""
Label5.Text = ""
Label6.Text = ""
End Select
End Sub
Ok.
Here it is.
First, in the table on your SQL server, set the Primary Key.
Here's how to do it.
Make sure that it is the corresponding field as in your access database.
Then, immediatly after the line accConnection.Close()
.
Add these lines:
For Each row As DataRow In table.Rows
row.SetAdded()
Next
This will ensure that the state of each row is not unmodified. Which in turn will make the sqlDataAdapter.Update(table) run an INSERT query. Thus adding the information to your sql database.
Ok.
Then let's try this.
Replace the e.Graphics.DrawString..... with
e.Graphics.DrawString(line, Me.Font, Brushes.Black, leftMargin, yPosition)
Could you be more specific, "it" is not very descriptive?
Which line gives the error? And what object?
Perhaps if you try changing the line Private WithEvents prn As Printing.PrintDocument
into Private WithEvents prn As New Printing.PrintDocument
Ok.
Then change the line: Dim text() As String = RichTextBox1.Lines into this:
Dim text() As String = New String() {Textbox1.Text, Textbox2.Text, and so on}
And change myBrushes to myBrush.
You can create a string parser of some type.
Dim request As WebRequest = HttpWebRequest.Create("http://www.mysite.com/")
Dim response As WebResponse = request.GetResponse()
Dim stream As Stream = response.GetResponseStream()
Dim reader As New StreamReader(stream)
Dim line As String
While reader.Peek > -1
line = reader.ReadLine()
If line.Contains("href") Then
'Do something with this line containing a href tag.
End If
End While