Oxiegen 88 Basically an Occasional Poster Featured Poster

Ok. Try and see if this works.
If I'm right, it will replace all occurences of the given "find" string within the file.

Private Sub FindAndReplace(ByVal FileName As String, ByVal find As String, ByVal replace As String)
        Dim fs As IO.FileStream
        fs = New IO.FileStream(FileName, IO.FileMode.OpenOrCreate)

        Dim buffer() As Byte
        Using br As New IO.BinaryReader(fs)
            buffer = br.ReadBytes(fs.Length)
        End Using
        fs.Close()

        fs = New IO.FileStream(FileName, IO.FileMode.Create)
        Dim text As String = System.Text.Encoding.UTF8.GetString(buffer).Replace(find, replace)
        Using bw As New IO.BinaryWriter(fs)
            buffer = System.Text.Encoding.UTF8.GetBytes(text)
            bw.Write(buffer)
        End Using

        MessageBox.Show("Finished", "", MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Sub
Oxiegen 88 Basically an Occasional Poster Featured Poster

I understand.
Can you post your code for the search and replace?
Perhaps we can take a look and see what the problem is.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Oops. Didn't look at the name of the poster. My bad. :)

You can create a structure outside the class and make it public.
Now it will be accessible from anywhere.

Public Structure individuo
   Dim x() As Double
   Dim fx As Double
End Structure
Public Structure poblacion
   Dim ind() As individuo
End Structure

Public Class Cruce
...
End Class
Oxiegen 88 Basically an Occasional Poster Featured Poster

What are the properties for the report file?

Check "Build Action", if it's set to Embedded Resource, then change that to None.
Check "Copy to Output Directory", if it's set to Do not copy, then change that to Copy always.

You need to make sure that the report file resides in the directory you are trying to load it from.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Why do you add 45 to GcoinPoints every time you click the button, regardless if you win or lose?

This is three losing rounds:
First round: GcoinPoints = 45
Second round GcoinPoints = 90
Third round GcoinPoints = 135

That could be the reason for problem 1, that the score is increasing in large chunks.
For problem 3, try to limit the random generator to choose between a set number of integers, like 1-10.
That would probably increase the odds.

Dim rnd As New Random
Dim value1 As Integer = rnd.Next(1, 10)
Dim value2 As Integer = rnd.Next(1, 10)
Oxiegen 88 Basically an Occasional Poster Featured Poster

On line 8, do this: cryRpt.Load(Application.StartupPath & "\Hir.rpt")

Oxiegen 88 Basically an Occasional Poster Featured Poster

Application.StartupPath points to the folder where your appliction is executed from.

For example, if you install your application to "C:\SomeKindOfApp\myapp.exe", then Application.StartupPath will point to "C:\SomeKindOfApp".

So, if the report you wish to load is on another disk, then Application.StartupPath won't work.
However, if the report file is located in the same folder as your executable, then Yes, Application.StartupPath will work perfectly.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Assuming that the error occurs on line 8, then the most likely cause is the path.
Is it correct?

Oxiegen 88 Basically an Occasional Poster Featured Poster

I see.
But your original question was "Is it possible to assign a method to a variable?".
And the answer is No, which is why I gave you a solution, that you built your own solution on.

Now I'm asking you, does it work?
Is your problem solved?

Oxiegen 88 Basically an Occasional Poster Featured Poster

I see.
Well, if you want to load a database from another drive you will have to change that.
In other words, replace Application.StartupPath with a hardcoded path: D:\<path_to_database>\Payment.mdb

Oxiegen 88 Basically an Occasional Poster Featured Poster

Yes. You do that in the connection string.
Assuming that you're using an Access database, then the connection string might look something like this.
Notice the Data Source path.

Dim con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\mydatabase.mdb;User Id=admin;Password=;")
Oxiegen 88 Basically an Occasional Poster Featured Poster

Ok. Three questions.
What does button1 open?
How far have you come yourself?
Have you tried searching for the solution, either here or on Google?

Oxiegen 88 Basically an Occasional Poster Featured Poster

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?

Oxiegen 88 Basically an Occasional Poster Featured Poster

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.

Oxiegen 88 Basically an Occasional Poster Featured Poster

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
Oxiegen 88 Basically an Occasional Poster Featured Poster

Just put the code in the keypress event.

Oxiegen 88 Basically an Occasional Poster Featured Poster

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
Oxiegen 88 Basically an Occasional Poster Featured Poster

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.

Oxiegen 88 Basically an Occasional Poster Featured Poster

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.

Oxiegen 88 Basically an Occasional Poster Featured Poster

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()
Oxiegen 88 Basically an Occasional Poster Featured Poster

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.

Oxiegen 88 Basically an Occasional Poster Featured Poster

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
Oxiegen 88 Basically an Occasional Poster Featured Poster

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.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Glad to be of help. :)
Please mark this thread as solved.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Glad to be of help. :)
Please mark this thread as solved.

Oxiegen 88 Basically an Occasional Poster Featured Poster

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?

Oxiegen 88 Basically an Occasional Poster Featured Poster

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
Oxiegen 88 Basically an Occasional Poster Featured Poster

What are you trying to do?

Oxiegen 88 Basically an Occasional Poster Featured Poster

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.

Oxiegen 88 Basically an Occasional Poster Featured Poster

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 .

Oxiegen 88 Basically an Occasional Poster Featured Poster
Oxiegen 88 Basically an Occasional Poster Featured Poster

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.

Oxiegen 88 Basically an Occasional Poster Featured Poster

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.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Is this the code you posted in the thread "Print Problem"?
And are the textboxes printed after the text?

Oxiegen 88 Basically an Occasional Poster Featured Poster

I don't understand what you mean by that.
Does the text lines have borders or something?

Oxiegen 88 Basically an Occasional Poster Featured Poster

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(...) ?

Oxiegen 88 Basically an Occasional Poster Featured Poster

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.

Oxiegen 88 Basically an Occasional Poster Featured Poster

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
Oxiegen 88 Basically an Occasional Poster Featured Poster

Ok.
Then let's try this.
Replace the e.Graphics.DrawString..... with
e.Graphics.DrawString(line, Me.Font, Brushes.Black, leftMargin, yPosition)

Oxiegen 88 Basically an Occasional Poster Featured Poster

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

Oxiegen 88 Basically an Occasional Poster Featured Poster

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.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Assuming that your text is in a RichTextBox control.
Try this:

Public Class Form1
   Private WithEvents prn As Printing.PrintDocument

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

   Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
      prn.Print()
   End Sub

   Private Sub prn_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles prn.PrintPage
      Dim linesPerPage As Single = 0
      Dim yPosition As Single = 0
      Dim count As Integer = 0
      Dim leftMargin As Single = e.MarginBounds.Left
      Dim topMargin As Single = e.MarginBounds.Top
      Dim printFont As Font = Me.Font
      Dim myBrush As New SolidBrush(Color.Black)
      Dim text() As String = RichTextBox1.Lines

      linesPerPage = e.MarginBounds.Height / printFont.GetHeight(e.Graphics)

      Try
         For i As Integer = 0 To text.Length - 1
            If count < linesPerPage Then
               yPosition = topMargin + (count * printFont.GetHeight(e.Graphics))
               e.Graphics.DrawString(text(i), printFont, myBrush, leftMargin, yPosition, New StringFormat())
               count += 1
            Else
               Exit For
            End If
         Next
      Catch ex As Exception
      End Try
      'This is needed
      e.HasMorePages = True
      e.HasMorePages = False
      myBrushes = Nothing
   End Sub
End Class
Oxiegen 88 Basically an Occasional Poster Featured Poster

You're welcome. :)
Please mark the thread as solved if this has been helpful.

Oxiegen 88 Basically an Occasional Poster Featured Poster

On what line is the error thrown?
Did you add the Public Enum outside the class definition?

Oxiegen 88 Basically an Occasional Poster Featured Poster

Well.
You have the MouseEnter, MouseLeave and Click events.
And you also have the Width and Height properties.

Oxiegen 88 Basically an Occasional Poster Featured Poster

*accidental double post*

Oxiegen 88 Basically an Occasional Poster Featured Poster

Yes, there is.
This is a quick sample of how to accomplish that.

This is the button click.

Private Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click
   Dim login As LoginReturnCodes
   Dim lif As New LoginForm()
   If lif.ShowDialog() = DialogResult.OK Then
      login = lif.Success
   End If
   lif.Dispose()

   If login = LoginReturnCodes.Success Then
      'Do some coding for successful login
   ElseIf login = LoginReturnCodes.Failure Then
      MessageBox.Show("Login failed. Please try again.")
   Else
      'Do nothing
   End If
End Sub

Assuming that you already have a form in place for username and password, with a Login button and a Cancel button.
For the form, set the property AcceptButton to the Login button, and the property CancelButton to your Cancel button.
This is code for the login form.

Public Enum LoginReturnCodes
   Success = 0
   Failure = 1
End Enum

Public Class LoginForm
   Private _success As LoginReturnCodes

   Private Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click
      'Do some checking if username and password are valid
      'If valid, set _success to LoginReturnCodes.Success
      'If not valid, set _success to LoginReturnCodes.Failure

      Me.Close()
   End Sub

   Private Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.Click
      Me.Close()
   End Sub

   Public ReadOnly Property Success() As LoginReturnCodes
      Get
         Return _success
      End Get
   End Property
End Class
Oxiegen 88 Basically an Occasional Poster Featured Poster

I'm assuming that you have a DataGridView on your form, named DataGridView1.

Dim cn As New OledbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\Wise-fps01\shared\vbDataBase.mdb")
        cn.Open()

        Dim adapter As OleDbDataAdapter = New OleDbDataAdapter("SELECT * FROM marketingDB WHERE company_name = 'Opfer Logan'", cn)

        Dim table As New DataTable()
        adapter.Fill(table)
        cn.Close()

        DataGridView1.DataSource = table
        DataGridView.Update()
Oxiegen 88 Basically an Occasional Poster Featured Poster

You are probably getting an error because you are missing the field names in the INSERT query.
Try this:

Dim con As New SqlClient.SqlConnection("Server=iraq\SQLEXPRESS; Database=stats; Trusted_Connection=True;")
Dim com As New SqlClient.SqlCommand("insert into users (field1,field2,field3) values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "')", con)

Try
   con.Open()
   com.ExecuteNonQuery()
   con.Close ()
Catch ex As Exception
   ' This will give you the exact error of what's going wrong
   MessageBox.Show(ex.ToString())
End Try
Oxiegen 88 Basically an Occasional Poster Featured Poster

You can do this.
Add the breakpoint, then right-click on the mark and select Location.
In the dialog-box that pops up, check the box "Allow the source code to be different from the original version". Hit OK.
That should work.