TnTinMN 418 Practically a Master Poster

An easy way to do this is to create a string collectionin My.Settings.

You can add/delete from it like any other list. Set it as the Listbox's DataSource.
ListBox1.DataSource = My.Settings.History

Just make sure that user settings is set to automatically save or do it in your code in the form closed event handler.

 Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
   My.Settings.Save()
End Sub

Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
My.Settings.Save()
End Sub

TnTinMN 418 Practically a Master Poster

I'm not going to claim that this is a better way, but it is one way that I find easy to read and work with.

      ' This method uses a CopmmandBuilder to build the commands

      ' You need to provide a DataApater with the select command defined
      ' for the command builder to work from.

      ' Since you are using all columns, a simple select * works

      Dim conn As New SqlConnection(My.Settings.NorthwindConnectionString)

      Dim adapter As New SqlDataAdapter()
      adapter.SelectCommand = New SqlCommand("Select * From Employees", conn)

      ' feed the adapter into the builder
      Dim cmdbuilder As New SqlCommandBuilder(adapter)

      ' get the insert command. Tell it to use column names for paramters
      Dim inscmd As SqlCommand = cmdbuilder.GetInsertCommand(useColumnsForParameterNames:=True)
      ' now just fill the parameters
      ' the name format is: @ColumnName
      ' in the column name has a space(" ") in it, it is replaced with "_"

      With inscmd
         .Parameters("@Last_Name").Value = "Jones"
         .Parameters("@First_Name").Value = "William"
         .Parameters("@Title").Value = "CCABW"
         .Parameters("@TitleofCourtesy").Value = "Mr."
         .Parameters("@BirthDate").Value = #1/1/1955#
         .Parameters("@HireDate").Value = #6/23/1978#
         .Parameters("@Address").Value = "Somewhere"
         .Parameters("@City").Value = "MyTown"
         .Parameters("@Region").Value = "All"
         .Parameters("@PostalCode").Value = "24312"
         .Parameters("@Country").Value = "USA"
         .Parameters("@HomePhone").Value = "1234332345"
         .Parameters("@Extension").Value = ""
         .Parameters("@Photo").Value = DBNull.Value
         .Parameters("@Notes").Value = ""
         .Parameters("@ReportsTo").Value = 4
         .Parameters("@PhotoPath").Value = ""
      End With

      conn.Open()
      inscmd.ExecuteNonQuery()
      conn.Close()
Reverend Jim commented: Another neat trick. +0
TnTinMN 418 Practically a Master Poster

@moodylv: You are in the wrong forum. That is VB.Net code.
I will ask a moderator to move this. For future reference, this is the correct forum: http://www.daniweb.com/software-development/vbnet/58

Take a look at this article:

How to: Read From Comma-Delimited Text Files in Visual Basic

In the example change:

MyReader.TextFieldType = FileIO.FieldType.Delimited
MyReader.SetDelimiters(",")

to:

MyReader.TextFieldType = FileIO.FieldType.Delimited
MyReader.SetDelimiters(" ") ' your file is space delimited
TnTinMN 418 Practically a Master Poster

Uhm, did you import the System.Xml namespace like I showed?

That was tested against the file you showed and functions fine.

TnTinMN 418 Practically a Master Poster

I don't know about using LINQ for this, but I would do it like this.

            using System.Xml;
            .
            .
            .
            XmlDocument doc = new XmlDocument();
            doc.Load("source.xml");
            // if you have the xml in a string use doc.LoadXml(stringvar)

            XmlNamespaceManager nsmngr = new XmlNamespaceManager(doc.NameTable);
            XmlNodeList results = doc.DocumentElement.SelectNodes("child::result", nsmngr);

            foreach (XmlNode result in results)
            {
                XmlNode namenode = result.SelectSingleNode("name");
                XmlNodeList types = result.SelectNodes("type");
                foreach (XmlNode type in types)
                {
                    Console.WriteLine(type.InnerText);
                }
                XmlNode fmtaddress = result.SelectSingleNode("formatted_address");
            }
TnTinMN 418 Practically a Master Poster

@Jhai,

It may help if you request that a moderator "sticky" this thread for a month or two. Just make a posting and flag it as a bad post (I really dislike the name they use to request moderator attention).

I also suggest that you request that the title be changed to something like:

Please vote for "MS to update VB6" - we have their attention - Act Now!

TnTinMN 418 Practically a Master Poster

Attached is a simple command window redirector that you can follow as an example.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {

        StreamWriter wtr;
        Process p;

        public Form1()
        {
            InitializeComponent();

        }

        private void button1_Click(object sender, EventArgs e)
        {
            string cmd = textBox2.Text.Trim();
            if (!string.IsNullOrEmpty(cmd))
            {
                wtr.WriteLine(cmd);
            }

        }

        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            p.Kill();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            ProcessStartInfo si = new ProcessStartInfo();
            {
                si.Arguments = "/k dir *.*";
                si.FileName = "cmd.exe";
                si.UseShellExecute = false;
                si.RedirectStandardOutput = true;
                si.RedirectStandardInput = true;
                si.CreateNoWindow = true;
            }

            p = new Process();
            p.StartInfo = si;
            p.OutputDataReceived += OutputHandler;
            p.Start();
            p.BeginOutputReadLine();
            wtr = p.StandardInput;
        }

        private void OutputHandler(object sendingProcess, DataReceivedEventArgs e)
        {
            if (textBox1.InvokeRequired)
            {
                this.Invoke(new System.Diagnostics.DataReceivedEventHandler(OutputHandler), new object[] {
                sendingProcess,
                e
            });
                return;
            }
            if (!string.IsNullOrEmpty(e.Data))
                textBox1.AppendText(e.Data + System.Environment.NewLine);
        }
    }
}
TnTinMN 418 Practically a Master Poster

I wish you the best of luck with this.

If MS does finally see the light and provide an update, I hope that they also will have the sense to draw the line on the .Net side of things and admit that it is not a natural progression from VB6 and in doing so eliminate the stuff in it that tries to tie it back to VB6. That stuff only confuses people.

AndreRet commented: my thoughts exactly. :) +13
TnTinMN 418 Practically a Master Poster

Edit:
@Jim, sorry about this. Didn't mean to step on your toes. I got interrupted while posting and did not think to do a refresh before posting.
**********

No offence intended, but the logic of yours is very confusing. I'm not sure that this is much better. It does pretty much what Jim's did and builds the "where" clause on the fly. I downloaded your db and gave it a quick test and it seemed to work, but the logic is my interpretation of what you are trying to do.

   Dim genderclause As String = ""
   Dim statusclause As String = ""

   'set gender part
   If mbox.Checked And fbox.Checked Then
      genderclause = "((gender = 'Male') Or (gender = 'Female'))"
   Else
      If mbox.Checked Then genderclause = "(gender = 'Male')"
      If fbox.Checked Then genderclause = "(gender = 'Female')"
   End If

   'set status part
   If rbox.Checked And cbox.Checked Then
      statusclause = "((status = 'Regular') Or (status = 'Contractual'))"
   Else
      If rbox.Checked Then statusclause = "(status = 'Regular')"
      If cbox.Checked Then statusclause = "(status = 'Contractual')"
   End If

   Dim whereclause As String

   If genderclause.Length = 0 And statusclause.Length = 0 Then
      whereclause = "" ' no filter
   Else
      whereclause = " where " & If(genderclause.Length = 0, "", genderclause & If(statusclause.Length = 0, "", " AND ")) _
                              & If(statusclause.Length = 0, "", statusclause)


   End If

   Try

      Using conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & System.Environment.CurrentDirectory & "\employeedb.mdb;")
         conn.Open()
         Dim command As New OleDbCommand("select * from employees" & whereclause, conn)
         Dim …
TnTinMN 418 Practically a Master Poster

I am interpreting the OP's question to be how to disable those annoying navigation clicks.

This looks like much more code than it really is as I just cut it out of my browser class with all the included documentation.

Public Class Form1
   'Disables Navigation Sound
   Private Sub btnMuteNav_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMuteNav.Click
      CoInternetSetFeatureEnabled( _
      INTERNETFEATURELIST.DISABLE_NAVIGATION_SOUNDS, dwflags.SET_FEATURE_ON_PROCESS, True)
   End Sub

   'Enables Navigation Sound
   Private Sub btnUnMuteNav_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUnMuteNav.Click
      CoInternetSetFeatureEnabled( _
      INTERNETFEATURELIST.DISABLE_NAVIGATION_SOUNDS, dwflags.SET_FEATURE_ON_PROCESS, False)
   End Sub

#Region "Interop garblygoop"

   ''' <summary>
   ''' Enables or disables a specified feature control. 
   ''' </summary>
   ''' <param name="FeatureEntry">A value from the INTERNETFEATURELIST enumeration that indicates the feature control to enable or disable.</param>
   ''' <param name="dwFlags">Specifies where to set the feature control value. Can be one of the following values: </param>
   ''' <param name="fEnable">A BOOL that indicates that the feature control specified by FeatureEntry is enabled when fEnable is TRUE. </param>
   ''' <returns>S_OK-Success, E_FAIL-FeatureEntry is invalid. </returns>
   ''' <remarks>The SET_FEATURE_ON_PROCESS flag is available for all values of INTERNETFEATURELIST except FEATURE_LOCALMACHINE_LOCKDOWN. All other values of dwFlags are available only when FeatureEntry is FEATURE_LOCALMACHINE_LOCKDOWN or FEATURE_PROTOCOL_LOCKDOWN.  Note  You cannot enable FEATURE_LOCALMACHINE_LOCKDOWN with this method, because doing so would bypass initialization that is based on whether this feature is enabled when a process starts. To correctly enable FEATURE_LOCALMACHINE_LOCKDOWN, you must set a Feature Control Key in the registry. For more information, see Introduction to Feature Controls.  The CoInternetSetFeatureEnabled function was introduced in Microsoft Internet Explorer 6 …
TnTinMN 418 Practically a Master Poster

So a work associate told my that if I add the Microsoft Word Object Library to my reference a user would be able to strip the word document text and process the data as a new string. It seems I was misinformed. There is no way my company is going to pay the Microsoft Word licensing on the 11 computers I am planning to purchase for this project. Any advice on a work-around?

_

\mc-000\WebFTP\Drawings\LoveCalProcedures\65726210test.doc"

Does the Word Document absolutely need to be stored in the Word 97-2003 "doc" format? If it could be stored in the newer "docx" format, you can use the Open XML SDK 2.0 for Microsoft Office to read the file without any licensing issues.

Retrieving the document text is as simple as:

   Dim wpdoc As DocumentFormat.OpenXml.Packaging.WordprocessingDocument = WordprocessingDocument.Open("D:\My Documents\programming.docx", isEditable:=False)
   Dim body As DocumentFormat.OpenXml.Wordprocessing.Body = wpdoc.MainDocumentPart.Document.Body
   Dim doctext As String = body.InnerText
   wpdoc.Close()
TnTinMN 418 Practically a Master Poster

Ok, I misunderstood what you were trying to accomplish.

You can add a new column to the source datatable (assuming the datasource is a table) to hold the computed label. Then use this new column as your XValueMember. Depending on the complexity of the logic, you may be able to use an DataColumn Expression to automatically compute the new string. Worse case is to loop through the rows and set the new value.

TnTinMN 418 Practically a Master Poster

I am glad that you figured it out.

Now that that is out of the way, I suggest that you modify your code to dispose of the PictureBox image before assigning a new one to it.

            If IsNothing(picture) = False Then

                If frm.PB1.Image IsNot Nothing Then
                    frm.PB1.Image.Dispose()
                    frm.PB1.Image = Nothing
                End If
                frm.PB1.Image = picture
            Else
                MsgBox("Picture returned nothing")
            End If

This will release the previous image for garbage collection. If you don't your program will continue to use more and more memory.

TnTinMN 418 Practically a Master Poster

I am beginning to suspect that the issue is the MDI taskbar that shows up when you maximize a child form. I have attached a simple project for you to play with.

MDI1

Begginnerdev commented: That was nice of you. +8
TnTinMN 418 Practically a Master Poster

How about just adding a title?

   Dim sometitle As New Title()
   With sometitle
      .Text = "Fred"
      .IsDockedInsideChartArea = True
      .Docking = Docking.Bottom
      .Alignment = ContentAlignment.MiddleCenter
   End With
   Chart1.Titles.Add(sometitle)
TnTinMN 418 Practically a Master Poster

try following this pattern instead,

   Dim dt As New DataTable
   Dim r As DataRow
   '*************************
   ' simulate Database Load
   With dt
      .Columns.Add("FromDataBase", GetType(Double))
      r = .NewRow : r(0) = 5 : .Rows.Add(r)
      r = .NewRow : r(0) = 15 : .Rows.Add(r)
      r = .NewRow : r(0) = 25 : .Rows.Add(r)
      r = .NewRow : r(0) = 55 : .Rows.Add(r)
   End With
   '*************************

   'add your new column to the datatable not the DGV
   Dim col1 As New DataColumn("Column1", GetType(Double))
   dt.Columns.Add(col1)
   col1.SetOrdinal(0) ' make it the first column
   DataGridView1.DataSource = dt

   ' sum columns
   r = dt.NewRow
   r(0) = dt.Compute("Sum([Column1])", filter:="True")
   r(1) = dt.Compute("Sum([FromDataBase])", filter:="True")
   dt.Rows.Add(r)
TnTinMN 418 Practically a Master Poster

It's like if you take all your money out of the bank and start spending it. You might feel rich but in fact you are rapidly getting poorer.

Is that along the lines of: it gives you that warming you get after wetting youself that ultimately turns into a wet smelly mess?

TnTinMN 418 Practically a Master Poster

There is no need to drop the hash marks. The parser accepts them as delimiting the start and end of datetime value. They are also used to hardcode datetime types.
Dim sometime As DateTime = #2/2/3003 1:00:00 PM#

It could be that the other programmer used MS's InvariantCulture when coding the service. It is just that this culture's DateTimeFormatInfo is identical (not verified) to the US culture's DateTimeFormatInfo property.

TnTinMN 418 Practically a Master Poster

Here is a novel concept to try. 9.1.3. Date and Time Literals

TnTinMN 418 Practically a Master Poster

A Datetime variable holds no culture specific information. You can however create a string representation for a specific culture.

I'm a bit lost as to whether you are trying to convert a string value from your service or convert to string value to send to your service.

Here are some examples:

   Dim US As New Globalization.CultureInfo("en-US")
   Dim GB As New Globalization.CultureInfo("en-GB")

   Dim dt1 As DateTime = DateTime.Parse("Thursday, January 24, 2013", US)
   Dim dt2 As DateTime = DateTime.Parse("Thursday, January 24, 2013", GB)
   MsgBox("dt1 = dt2: " & (dt1 = dt2).ToString)

   dt1 = DateTime.Parse("1/24/2013", US)
   dt2 = DateTime.Parse("24.01.2013", GB)
   MsgBox("dt1 = dt2: " & (dt1 = dt2).ToString)

   ' format ref: http://msdn.microsoft.com/en-us/library/az4se3k1%28v=VS.71%29.aspx
   Dim strdt1v1 As String = dt1.ToString(format:="D", provider:=US)
   Dim strdt1v2 As String = dt1.ToString(format:="D", provider:=GB)

   dt1 = Now() ' give a time component
   'DateTimeFormatInfo.RFC1123Pattern - this the same format for all cultures
   ' http://msdn.microsoft.com/en-us/library/system.globalization.datetimeformatinfo.rfc1123pattern%28v=vs.90%29.aspx
   ' (strdt1Internetv1=strdt1Internetv2) = true
   Dim strdt1Internetv1 As String = dt1.ToString(format:="R", provider:=US)
   Dim strdt1Internetv2 As String = dt1.ToString(format:="R", provider:=GB)

   Dim strdt1Internetv3 As String = dt1.ToString(format:=US.DateTimeFormat.RFC1123Pattern)
   Dim strdt1Internetv4 As String = dt1.ToString(format:=GB.DateTimeFormat.RFC1123Pattern)
   Dim strdt1Internetv5 As String = dt1.ToString(format:=Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.RFC1123Pattern)
TnTinMN 418 Practically a Master Poster

I just had another thought, try moving your maximize code from the Load handler to the Shown handler.

TnTinMN 418 Practically a Master Poster

Have you some how set the MaximumSize property to something other than Size.Empty?

TnTinMN 418 Practically a Master Poster

Use the ActiveX ComboBox. It has a change event that you can handle. Also the changes that it makes to the linked cell also triggers the WorkSheet_Change event. The Forms drop down does not do this.

TnTinMN 418 Practically a Master Poster

Random is a pseudoRandom generator. You are creating a new instance each time. Without checking the docs, I believe it seeds based on system time. Therefore your seed value on differs only a bit on each creation.

Try this:

Private rnd As New Random
Private Sub Me_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Shown

   DrawColor(New Rectangle(50, 50, 100, 100))
    For i As Int32 = 0 To 20
        DrawColor(GimmiRectangle)
    Next
End Sub

Private Sub DrawColor(ByVal rNew As Rectangle)
    Try
        Dim g As Graphics = Me.CreateGraphics

        g.DrawRectangle(New Pen(Color.FromArgb(rnd.Next(255), rnd.Next(255), rnd.Next(255))), rNew)
        g.Dispose()

    Catch ex As Exception
        MsgBox(ex.ToString)
    End Try
End Sub

Private Function GimmiRectangle() As Rectangle
    Try
        Dim rect As New Rectangle(rnd.Next(1000), rnd.Next(1000), rnd.Next(1000), rnd.Next(1000))
        Return rect
    Catch ex As Exception
        MsgBox(ex.ToString)
        Return New Rectangle(0, 0, 0, 0)
    End Try
End Function
TnTinMN 418 Practically a Master Poster

Update the underlying datatable directly. This will ensure that the changes are reflected in the dataview.

Something like this:

Public Class Form1

   Dim dtSource As New DataTable
   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

      Dim r As DataRow
      With dtSource
         .Columns.Add("store", GetType(String))
         .Columns.Add("hours", GetType(Double))
         r = .NewRow : r(0) = "s1" : r(1) = 3.0# : .Rows.Add(r)
         r = .NewRow : r(0) = "s1" : r(1) = 5.0# : .Rows.Add(r)
         r = .NewRow : r(0) = "s1" : r(1) = 51.0# : .Rows.Add(r)
         r = .NewRow : r(0) = "s1" : r(1) = 13.0# : .Rows.Add(r)
         r = .NewRow : r(0) = "s1" : r(1) = 33.0# : .Rows.Add(r)
         r = .NewRow : r(0) = "s2" : r(1) = 35.0# : .Rows.Add(r)
         r = .NewRow : r(0) = "s2" : r(1) = 54.0# : .Rows.Add(r)
         r = .NewRow : r(0) = "s2" : r(1) = 23.0# : .Rows.Add(r)
         r = .NewRow : r(0) = "s2" : r(1) = 31.0# : .Rows.Add(r)
         .DefaultView.Sort = "[hours] Asc"
      End With
      DataGridView1.DataSource = dtSource.DefaultView
   End Sub


   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      AddhoursToStore("s1", 50.0#)
   End Sub

   Sub AddhoursToStore(ByVal store As String, ByVal hrsToAdd As Double)
      For Each row As DataRow In dtSource.Select("[store] = '" & store & "'")
         row("hours") = CType(row("hours"), Double) + hrsToAdd
      Next
   End Sub
End Class
TnTinMN 418 Practically a Master Poster

VBA is a subset of VB6, so I think that would be the best place.
http://www.daniweb.com/software-development/visual-basic-4-5-6/4

TnTinMN 418 Practically a Master Poster

I've also done something with tab controls before and hooking into the draw at run time to hide the actual tabs showing, then programatically hopping between the two

This works well if you want to keep all the controls and their handlers under one form.

The method I use is to set the DrawMode to OwnerDrawn fixed, Appearance to "Buttons" and the ItemSize to (5,5).

This allows you to click on the the buttons to change Tabs while in the designer and does not take away much design space.

The wrinkle that I throw in is to place a docked panel as the first control on each tab. Then all other controls are parented to that panel.

The tabcontrol is parented in a panel on the form during design. I set tabcontrol's Parent property to null on loading the form. This leaves it fully functional just hidden and out of the way.

I then play a Parent swap game with each TabPage's first control (the panel mentioned above) by setting it's Parent property to the panel that originally parented the tabcontrol. I use the SelectedTab property to keep track of whick panel is currently parented to the form.

Mike Askew commented: Another good implementation +6
TnTinMN 418 Practically a Master Poster

There is a more complete example here: http://msdn.microsoft.com/en-us/library/system.diagnostics.process.beginoutputreadline%28v=vs.90%29.aspx

Other than that follow tinstaffl advice.

TnTinMN 418 Practically a Master Poster

What did you not understand about the information that I provided you? You still have the issues no matter which method you use to convert the byte array to an image. If the the byte array is null, it will fail.

Begginnerdev commented: Some people will never learn. +8
TnTinMN 418 Practically a Master Poster

Here is another option using the FileSystemObject

Sub ListDrives()
    Dim fso As Scripting.FileSystemObject 'needs refernce to: Microsoft Scripting Runtime
    Dim fsoDrives As Scripting.drives

    Set fso = New FileSystemObject
    Set fsoDrives = fso.drives
    Dim i As Integer
    Dim letter As String
    Dim driveType As String
    For i = Asc("A") To Asc("Z")
        letter = Chr$(i)
        If fso.DriveExists(letter) Then
            Select Case fso.drives(letter).driveType 'returns DriveTypeConst
                Case Scripting.UnknownType
                    driveType = "Unknown"
                Case Scripting.Removable
                    driveType = "Removable"
                Case Scripting.Fixed
                    driveType = "Fixed"
                Case Scripting.Remote
                    driveType = "Remote"
                Case Scripting.CDRom
                    driveType = "CDRom"
                Case Scripting.RamDisk
                    driveType = "RamDisk"
            End Select
            MsgBox "Drive " & letter & " - " & driveType
        End If
    Next i

    Set fsoDrives = Nothing
    Set fso = Nothing

End Sub
TnTinMN 418 Practically a Master Poster

The error message indicates that "pictureData" is null (Nothing).

Make sure your query is correct and check for null before converting to an Image.

If pictureData IsNot Nothing Then

Another issue that you may run into using the ExecuteScalar command is the size limit that it can return. From the documentation on the return value:

The first column of the first row in the result set, or a null reference (Nothing in Visual Basic) if the result set is empty. Returns a maximum of 2033 characters

You may want to consider using a datareader instead and use reader.GetValue(0).

TnTinMN 418 Practically a Master Poster

Here is my 2 cents worth for something to check. You mention 64-bit repeatedly. Are you trying to target 64 bit? One of the DLL's may be 32-bit only. I believe that it would run fine under VS as VS is a 32-bit app.

TnTinMN 418 Practically a Master Poster

If you are only showing the first column, then I suspect you may not have the ListView configured correctly. I don't use this control very often, but for three columns, I would do it like this:

      With ListView1
         .View = View.Details
         .HeaderStyle = ColumnHeaderStyle.None ' set to whatever you need
         .Columns.Clear() ' make sure collumnscollection is empty
         ' Add 3 columns
         .Columns.AddRange(New ColumnHeader() {New ColumnHeader(), New ColumnHeader(), New ColumnHeader()})
      End With
TnTinMN 418 Practically a Master Poster

You played that " I'm just a student starting to learn vb.net and more on searching codes for editing and applying to my app" 3 momths ago.

Instead of looking for code to cobble together into something that satifies your instructor, try learning from what you find. If you don't understand something try reading the documentation and if that still does not gel into an understanding ask specific questions asking why something does what it does.

Don't come here with that line of "poor little ol' me is just too confused, will you do my homework for me" line.

TnTinMN 418 Practically a Master Poster

To make that work you need to have Option Strict Off which is something I personally do not care for, but to each their own.

You are forcing a narrowing implicit conversion on the method signature (delegate). Based on Variance in Delegates (C# and Visual Basic) I believe you are safe.

TnTinMN 418 Practically a Master Poster

try changing you code like this to verify that that the brush is not null

        For a = 0 To 4
            Dim imageID As Int16 = Junk(a, 0)
            If tBrushArray(imageID) Is Nothing Then Stop
            If Junk(a, 0) > 0 Then
                junkSprite.MakeTransparent(Color.Fuchsia)
                g.Graphics.FillRectangle(tBrushArray(imageID), tJunk(a))
            End If
        Next

This will cause the debugger to stop if the brush is null and then you can inspect the variables to see what is going on. If it does not stop then something else is going on.

TnTinMN 418 Practically a Master Poster

Err is in this line:

g.Graphics.FillRectangle(tBrushArray(imageID), tJunk(a))

Many of the elements (indices: 0, and 9 thru 19) in tBrushArray are set to Nothing (null).

So if imageID equals one of those indices, you are passing a null (VB Nothing) brush like your error message indicates is the problem.

TnTinMN 418 Practically a Master Poster

Are you using the Visual Basic source code editor to enter your code?
If so, try paying attention to the IntelliSence prompts.
It informs you that you need to specify the column to retrieve for the GetString method.

TnTinMN 418 Practically a Master Poster

@Andre, did you by chance mean to use InstrRev in line 6 of your code?

Here's my entry for this mundane function.

Function RemoveExt(fname As String, Optional extToRemove As String = "") As String
    ' if extToRemove = "" then all extensions removed
    Dim pt_pos As Integer
    pt_pos = InStrRev(fname, ".")
    If pt_pos <> 0 Then
        If extToRemove = "" Then
            'Remove all extensions
            RemoveExt = Left(fname, pt_pos - 1)
        Else
            extpart = Right(fname, (Len(fname) - pt_pos) + 1)
            If LCase(extpart) = LCase(extToRemove) Then
                RemoveExt = Left(fname, pt_pos - 1)
            Else
                RemoveExt = fname
            End If
        End If
    Else
        RemoveExt = fname
    End If
End Function
AndreRet commented: Indded, because of more functionality :) +13
TnTinMN 418 Practically a Master Poster

I'm not sure this what you are attempting, but I have assumed:

  1. you need to read an xml source file
  2. you need to add a new "students" element
  3. you want to save the file with "students" sorted on "Day"

      Dim doc As New Xml.XmlDocument ' create a XMLDocument to hold the file
      doc.Load("SourceFile.xml")     ' load the file
    
      ' Since Events is your main element it is the "DocumentElement"
      Dim Events As Xml.XmlNode = doc.DocumentElement
    
      ' add a new "students" element to "Events"
         Dim elStudents As Xml.XmlElement = doc.CreateElement("students")
         Dim elDay As Xml.XmlElement = doc.CreateElement("Day")
         elDay.InnerText = "3"
         elStudents.AppendChild(elDay)
         Events.AppendChild(elStudents)
    
      ' since there are only "students" elements as child nodes of "Events", 
      ' all child nodes are "students"
    
      ' we will create a list that can be sorted and load it from "Events.ChildNodes"
    
      Dim sortedstudents As List(Of Xml.XmlElement) = _
         (From el In Events.ChildNodes Select CType(el, Xml.XmlElement)).ToList
    
      ' I am assuming that "Day" is an Integer;
      ' therefore, I am converting it to an Integer for comparison during sorting
    
      sortedstudents.Sort(Function(el1 As Xml.XmlElement, el2 As Xml.XmlElement) _
                           CInt(el1.SelectSingleNode("Day").InnerText).CompareTo( _
                           CInt(el2.SelectSingleNode("Day").InnerText)))
    
      Events.RemoveAll() ' Delete all exiting child nodes from Events
    
      ' now append the sorted "students" elements to the empty "Events" element
    
      For Each el As Xml.XmlElement In sortedstudents
         Events.AppendChild(el)
      Next
    
      ' save the processed file
      doc.Save("fred.xml")
    
TnTinMN 418 Practically a Master Poster

Please show a sample of your original xml file. Then manually create and show a sample of how it should look after it has been sorted.

TnTinMN 418 Practically a Master Poster

Just a bit of info to add to the discussion.

Your original code will give you your expected result if you change
objWriter.Write(editor.RichTextBox1.Text)
to
objWriter.Write(editor.RichTextBox1.Rtf)

Those dang computers always try to do what you tell them to do, not what you want them to do. :)

That said, its easier to use the Save and Load methods as Jim has shown you.

DyO152 commented: Thanks. +0
TnTinMN 418 Practically a Master Poster

To supplement BD's comment on brackets, this is from the documentation;

Any program element — such as a variable, class, or member — can have the same name as a restricted keyword. For example, you can create a variable named Loop. However, to refer to your version of it — which has the same name as the restricted Loop keyword — you must either precede it with a full qualification string or enclose it in square brackets ([ ]), as the following example shows.

My synopsis of this is that brackets tell the compiler and/or IDE that the bracketed word is not a VB keyword. No harm in using them.

TnTinMN 418 Practically a Master Poster

Is the DGV bound to a datatable?
Can you except the DGV showing only rows that match your search criteria?
If so, consider using setting the row filter on the datatable's DefaultView or creating a DataView and using it as the DGV's datasource.

Begginnerdev commented: Very true +7
TnTinMN 418 Practically a Master Poster

I guess if you you have it formatted to a short date format, then allowing the user to invoke the dropdown to show the MonthCalndar may be of some use.

Anyways, making a readonly DTP control is fairly easy.

Public Class ReadOnlyDTP
   Inherits DateTimePicker
   Public Shadows Property Value() As DateTime
      Get
         Return MyBase.Value
      End Get
      Set(ByVal value As DateTime)
         ' Need to set values in correct order 
         ' to prevent internal validation error
         Select Case value
            Case Is < MyBase.Value
               MyBase.MinDate = value
               MyBase.Value = value
               MyBase.MaxDate = value
            Case Is > MyBase.Value
               MyBase.MaxDate = value
               MyBase.Value = value
               MyBase.MinDate = value
         End Select
      End Set
   End Property 'Value

   Const WM_Char As Int32 = &H102
   Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
      ' prevent keyboard changes to the fields
      If m.Msg = WM_Char Then Exit Sub
      MyBase.WndProc(m)
   End Sub
End Class

Add this to your project, build the project and it should showup in your ToolBox if your VS is configured to do so (it is the default setting).

Reverend Jim commented: I've been wanting just that trick for something else. Thanks. +12
TnTinMN 418 Practically a Master Poster

Well the problem being wide spread rules out my thought of a corrupted solution file.

If I remember correctly, last weeks update's from MS patched all versions of .Net (1.1 and up). There could have been something in those that is causing an issue. look in your update log and try uninstalling them.

My only other suggestion is one I dread doing as it is time consuming, but I would try removing VS again and also uninstall the .Net framework and then reinstall everything. The problem is that there is no guarranty that this would solve the problem.

TnTinMN 418 Practically a Master Poster

This behavior can occur if your source file (yourfilename.vb) somehow become posted dated in comparison to your current system datetime setting.

I posted some instructions on how to correct this condition here: Click Here

TnTinMN 418 Practically a Master Poster

Is this happening with all your projects or just one particular project?
Does it happen if you create a new project?

TnTinMN 418 Practically a Master Poster

Jim has a minor error in his code:

 "SELECT * FROM invoiced_filter " & _
" WHERE (Invoiced > #" & fromdte & "# AND Invoiced < #" & todte & "#)"

Access also supports the Between statement but it requires the hash mark ("#") as Jim shown.

 "SELECT * FROM invoiced_filter " & _
" WHERE (Invoiced Between #" & fromdte & "# AND Invoiced < #" & todte & "#)"
Reverend Jim commented: That's why I like to test these things before posting ;-P +12
TnTinMN 418 Practically a Master Poster

Problem is on your instent name(REHAN-PC\SQLEXPRESS).When your connecting to SQL Server Management Studio, do not use your PC name.use only .\SQLEXPRESS.

You are assuming that the Instance Name is SQLExpress. This may not be the case.