1.11M Members

Posts by Oxiegen which have been Voted Up

Re: in VB.NET
 
1
 

Just for kicks.
Try putting that code in a separate method and call it from the Load method.
But also include a class boolean variable.

Private bIsLoading As Boolean = True

Private Sub frmcrc_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    If bIsLoading Then
        LoadValues()
    End If
    bIsLoading = False
End Sub

Private Sub LoadValues()
    'Your code
End Sub

This is just to make sure that the code is not being executed twice.
I've had the happen to me once or twice when I had some code in the Form_Load event.

Re: in Computer Science
 
1
 

DIM is the keyword used in Visual Basic to declare a variable.

VB: Dim varname As Object
C#: object varname;

Re: in VB.NET
 
1
 

If you create and add controls through code then those controls will not have any events tied to them.
When you open the second and third panels and create controls in them, you also have to use the AddHandler statement and tie that to the txbUM_KeyDown event, or use a generic event and tie all three textboxes to it using AddHandler.

'For panel 2
AddHandler txbUM2.KeyDown, AddressOf txbUM_KeyDown

'For panel 3
AddHandler txbUM3.KeyDown, AddressOf txbUM_KeyDown

Like that.
And in the event itself you can use sender to identify which textbox triggered the event by using CType.

Dim tbox As TextBox = CType(sender, TextBox)
Re: in Web Development
 
1
 

I cannot speak for all the webhosts in the world.
However, I would say that some webhosts provide such a solution, provided that you register a domain with them.
But most do not. They require that you order the full package of a webspace that includes 5, or more, email addresses.

But to answer your question.
Yes. It's possible.

How about this example? http://www.mailorderworks.co.uk/

Re: in Web Design, HTML and CSS
 
1
 

The question mark (?) was just an indicator telling you to put a numeric value there.
A question mark is also known as an "unknown". :)

Auto is not a property, it's a valid value to simply allow the container to expand depending on whatever the size of the content without regards.

Re: in VB.NET
 
1
 

Something like this:

Private Sub CopyToAccess(source As DataTable)
    Try
        Dim connString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccess2007file.accdb;Persist Security Info=False;"

        Dim accConnection As New OleDb.OleDbConnection(connString)
        Dim selectCommand As String = "SELECT <field1>, <field2> and so on FROM <table>"
        Dim accDataAdapter As New OleDb.OleDbDataAdapter(selectCommand, accConnection)

        Dim accCommandBuilder As New OleDb.OleDbCommandBuilder()
        accDataAdapter.InsertCommand = accCommandBuilder.GetInsertCommand()
        accDataAdapter.UpdateCommand = accCommandBuilder.GetUpdateCommand()

        Dim accDataTable As DataTable = source.Copy()

        ''Just to make sure, set the RowState to added to make sure an Insert is performed'
        'For Each row As DataRow In accDataTable.Rows'
        '    If row.RowState = RowState.Added Or RowSate.UnChanged Then'
        '        row.SetAdded()'
        '    End If'
        'Next'

        accDataAdapter.Update(accDataTable)
    Catch ex As Exception
    End Try
End Sub
Re: in VB.NET
 
1
 

Here's how you can get an ArrayList of available drives.

Imports System.IO

Public Function GetDrives() As ArrayList
    Dim drives As New ArrayList

    For Each drive As DriveInfo In My.Computer.FileSystem.Drives
        drives.Add(drive.Name)
    Next

    Return drives
End Function
Re: in VB.NET
 
1
 

I'm assuming that you're looking for the SQL expression to accomplish this.
Here it is:
SELECT tblData.num,SUM(tblData.cost) AS Total,tblPrize.prize FROM tblData, tblPrize WHERE tblData.num = tblPrize.num GROUP BY tblData.num

Re: in VB.NET
 
1
 

I've been successful in using IO.File.Copy when transfering files to and from another computer.
IO.File.Copy("\\" & cmbservername1.Text & "\SharedNow\database.txt", "C:\database.txt")

Re: in VB.NET
 
2
 

You should make it a rule to include an ID field and make it a Primary Key when creating tables in a database.
And also include that in your SELECT statements.

That's why you get that message.

Re: in VB.NET
 
1
 

Try setting the mdiparent of that second form to the MDI form.

mastersupplier.MdiParent = <name of mdi form>
Re: in VB.NET
 
1
 

Alright.
You want to convert the text into HTML entities.

This function should do it:

Private Sub SomeMethod()
   Dim file As New StreamReader("filename", Encoding.GetEncoder(437))
   Dim content As String
   content = TextToHtmlEntity(file.ReadToEnd)
   file.Close()

   'content now contains a string of HTML entities
End Sub

Private Function TextToHtmlEntity(ByVal text As String) As String
   Dim textVal As Integer
   Dim encoded As String = ""
   Dim c As Char

   For Each c In text
      textVal = AscW(c)
      If textVal >= 49 And textVal <= 122 Then
         encoded += c
      Else
         encoded += String.Concat("&#",
textVal.ToString(System.Globalization.NumberFormatInfo.InvariantInfo), ";")
      End If
   Next

   Return encoded
End Function
Re: in VB.NET
 
1
 

You can use the MouseMove event and check if the mouse pointer is within the Bounds of the stripmenu item.
If that's the case, simply change the BackgroundColor.

Private Sub menuitem1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs)
        If menuitem1.Bounds.Contains(e.Location) Then
            menuitem1.BackColor = Color.Beige
        Else
            menuitem1.BackColor = Color.White
        End If
    End Sub
Re: in VB.NET
 
1
 

Have you tried using HttpWebResponse.ResponseUri?

Dim response As HttpWebResponse
Dim resUri As String

response = request.GetResponse
resUri = response.ResponseUri.AbsoluteUri
Re: in C#
 
1
 

I'm using a single method for resizing images in both directions.
It returns a BitMap object that you can use on wherever you like.

public BitMap ResizeBitMap(BitMap source, Size newSize)
{
   //Get the source bitmap
   BitMap bm_source = source;

   //Create a bitmap for the result
   BitMap bm_dest = new BitMap(newSize.Width, newSize.Height);

   //Create a Graphics object for the resulting BitMap
   Graphics gr_dest = Graphics.FromImage(bm_dest);

   //Copy the source image into the destination bitmap
   gr_dest.DrawImage(bm_source, 0, 0, bm_dest.Width + 1, bm_dest.Height + 1);

   //Return the result
   return bm_dest;
}

Here is one way of how you can use it:

private void someMethod()
{
   BitMap resizedImage = ResizeBitMap(loadedImage, new Size(loadedImage.Width * .9, loadedImage.Height * .9));

   //Stick that resized bitmap anywhere you like it.
   //For example a PictureBox
   pictureBox1.Image = resizedImage;
}
Re: in VB.NET
 
1
 

Do you remember the connection string I gave you in your previous post "Need Help"?
Try using that one instead.

If I recall correctly, the constant DATA_SOURCE already contains "data source=JAKE-PC\SQLEXPRESS", so what you have done in your StingBuilder is declare the data source twice.
It's redundant, and causes errors.

And, the format of your connection string is targeted towards MSSQL 2005/2008.
Try using "Integrated Security=SSPI" instead of "trusted_connection=yes;".

Re: in VB.NET
 
1
 

If you wanna move or copy files from one location to another using your program, there are easier ways than using FileStream.

Imports System.IO

    Private Sub FileCopy()
        Dim strFileSource As String = "C:\Temp\sourceFile.txt"
        Dim strFileDestination As String = "C:\Temp\destinationFile.txt"

        File.Copy(strFileSource, strFileDestination)
    End Sub

    Private Sub FileMove()
        Dim strFileSource As String = "C:\Temp\sourceFile.txt"
        Dim strFileDestination As String = "C:\Temp\destinationFile.txt"

        File.Move(strFileSource, strFileDestination)
    End Sub

    Private Sub CopyMoveMultipleFiles()
        Dim strSourceDirectory As String = "C:\Temp"
        Dim strDestinationDirectory As String = "C:\SecondaryTemp"
        Dim di As New DirectoryInfo(strSourceDirectory)

        'To copy files
        For Each fi As FileInfo In di.GetFiles
            fi.CopyTo(strDestinationDirectory & "\" & fi.Name)
        Next

        'To move files
        For Each fi As FileInfo In di.GetFiles
            fi.MoveTo(strDestinationDirectory & "\" & fi.Name)
        Next
    End Sub
Re: in VB.NET
 
1
 

You should consider moving that code onto a button click event.
Otherwise the query will be fired for every keystroke you use in the textbox.

And you are very close to the solution, my friend. :)
Notice my lack of use of the SqlConnection object. It will work anyway, because the SqlDataAdapter will take care of connecting to the database. If provided with the connection string.

The SqlCommandBuilder will help take care of creating INSERT, UPDATE and DELETE statements for you.

Private bindingSource1 As New BindingSource

Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
   AuthorsGridView.DataSource = bindingSource1
End Sub

Private Sub TextBoxId_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBoxIdSearchExist.TextChanged
   Try
      da = New SqlDataAdapter("SELECT * FROM pay WHERE t_id = '" & tId.Text & "'", <your connection string>)
      Dim builder As New SqlCommandBuilder(da)
      da.Fill(ds, "pay") 'Needs to be the name of the source table
   
      'I don't know what GetData(queryString) is for, so I'm ignoring it
      If ds.Tables.Count > 0 Then
         bindingSource1.DataSource = ds.Tables(0)
      Else
         MessageBox.Show("No results found in database.")
      End If
   Catch ex As Exception
      MessageBox.Show("Unable to connect to database, or an error occured.")
   End Try
End Sub

Tag Cloud for Oxiegen