TnTinMN 418 Practically a Master Poster

Sorry, but I begin to use VBA and I want/need to learn more. I will be apreaciated for any clues.

I am going to assume that since you mentioned VBA that you are looking for Excel macro help.

If this is the case, this thread should be probably moved to the VB6 forum as that is the most appropriate one that I can think of.

TnTinMN,
Yes, it sounds like what I need.

Here is a basic macro with minimal error checking. It asks you to select two ranges and it compares the first column in each range to produce a result array. It then asks you for a place to copy the results to in a worksheet.

Private Sub CompareColumns()
    Dim Col1 As Range
    Dim Col2 As Range

    On Error Resume Next

    Set Col1 = Application.InputBox("Select 1st column", , ActiveCell.Address, _
                                        , , , , vbString)
    If Col1 Is Nothing Then Exit Sub

    Set Col2 = Application.InputBox("Select 2nd column", , ActiveCell.Address, _
                                        , , , , vbString)
    If Col2 Is Nothing Then Exit Sub

    On Error GoTo 0 ' cancel resume next

    'Determine the longer list

        Dim shortCol As Range
        Dim LongCol As Range

        If Col1.Rows.Count < Col2.Rows.Count Then
            Set shortCol = Col1
            Set LongCol = Col2
        Else
            Set shortCol = Col2
            Set LongCol = Col1
        End If

    Dim LongColMatched() As Boolean ' Used to indicate matched value used if duplicates exist
    ReDim LongColMatched(0 To LongCol.Rows.Count - 1)

    ' declare a result array …
Tarwit commented: excellent! well done! +0
Reverend Jim commented: Likewise +12
TnTinMN 418 Practically a Master Poster
TnTinMN 418 Practically a Master Poster

Also make sure that your application is compiled as a 32-bit application (x86).

Begginnerdev commented: Yeppers! +8
TnTinMN 418 Practically a Master Poster

The routine that I posted does not clone Children nor Content. It may be possible to write a generic cloner, but write know I do not see an easy way to do so.

It is be fairly easy to write a simple cloner for the pattern of ContentControl <- Grid <- Shape.

        private void Button1_Click(object sender, RoutedEventArgs e)
        {
            ContentControl cc = ContentControlCloner(ContentControl1);
            cc.Margin = new Thickness(100, 0, 0, 0);
            Canvas1.Children.Add(cc);
        }

        private Shape ShapeCloneProperties(Shape source)
        {
            Shape clone = null;

            switch (source.GetType().Name)
            {
                case "Ellipse":
                    clone = new Ellipse();
                    break;
                case "Line":
                    clone = new Line();
                    break;
                case "Path":
                    clone = new Path();
                    break;
                case "Polygon":
                    clone = new Polygon();
                    break;
                case "Polyline":
                    clone = new Polyline();
                    break;
                case "Rectangle":
                    clone = new Rectangle();
                    break;
                default:
                    throw new ArgumentException("Invalid shape");
            }

            foreach (System.Reflection.PropertyInfo pi in source.GetType().GetProperties())
            {
                if (pi.CanWrite && pi.CanRead)
                {
                    pi.SetValue(clone, pi.GetValue(source, null), null);
                }
            }

            return clone;
        }

        private ContentControl ContentControlCloner(ContentControl source)
        {
            ContentControl clone = new ContentControl();
            clone.Name = "fred";

            foreach (System.Reflection.PropertyInfo pi in typeof(ContentControl).GetProperties())
            {

                if (pi.Name == "Content")
                {
                    Grid gr = (Grid)source.Content;

                    Grid gridclone = GridCloneProperties(gr);

                    gridclone.Children.Clear();
                    Shape sh = ShapeCloneProperties((Shape)gr.Children[0]);
                    gridclone.Children.Add(sh);
                    clone.Content = gridclone;

                }
                else
                {
                    if (pi.CanWrite && pi.CanRead)
                    {
                        pi.SetValue(clone, pi.GetValue(source, null), null);
                    }

                }
            }
            return clone;

        }

        private Grid GridCloneProperties(Grid source)
        {
            Grid clone = new Grid();

            foreach (System.Reflection.PropertyInfo pi in typeof(Grid).GetProperties())
            {
                if (pi.CanWrite && pi.CanRead)
                {
                    pi.SetValue(clone, pi.GetValue(source, null), null);
                }
            }

            return clone;
        }

    }
TnTinMN 418 Practically a Master Poster

It is called a property.

see: Properties (C# Programming Guide)

TnTinMN 418 Practically a Master Poster

If I'm not mistaken, these user-scope settings will not be there when the application is restarted.

You are misktaken.

User-Scoped settings would be pretty useless if they could not be saved. The default is for them to be saved on application shutdown, but you can also issue the statement My.Settings.Save() to force a save of their current state.

savedlema commented: Alright. Thank you. I see I got that wrong. +2
TnTinMN 418 Practically a Master Poster

for example in VB.net ....

but in C# this doesn't seem to work, i can hide the form fine (this.hide();) but when in the second form i cannot recall the form (form1.show();) as it doesn't seem to exsist, but i tested it by taking out the .hide(); and it just sits in the background (unpleasant) lol

That is because VB.Net with the Application Framework enabled automagically creates and maintains a globally accessible instance of all forms in your project. This is one feature that I wish that they never implemented; it does make some things easier (I guess that was the intent), but it really messes with the minds of programmers who are not used to having objects automagically created and made accessible.

I really dislike the idea globally accessible objects and feel that a class needs a reference to an external object, that reference should be purposely set. The reference can either be a property or passed in the constructor.

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Form2 f2 = new Form2(this);
            this.Hide();
            f2.ShowDialog();
        }
    }
}

Now for Form2:

namespace WindowsFormsApplication1
{
    public partial class Form2 : Form
    {
        private Form _FormThatShowedMe;
        public Form2(Form FormThatShowedMe) // pass reference 
        {
            if (FormThatShowedMe == null)
            {
                throw new ArgumentException("Hey! I need a valid form");
            }
            InitializeComponent();
            _FormThatShowedMe = FormThatShowedMe;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            _FormThatShowedMe.Show();
            this.Close();
        } …
ddanbe commented: Totally agree! I like C# because it is so strict in many matters +14
TnTinMN 418 Practically a Master Poster

I take it that you are using VS2008 or ealier when we still had deployment projects.

The only way that I know that the "Add Project Output Group" dialog would be empty is if the startup project is the only one in the soultion that holds the setup project.
6eebd281bde234385681d372e56de8aa

What you are expecting is something like this where there is another project from which to populate the dialog.
109920d6946863407531412377f293ec

Please confirm that this is the situation or not.

Posting a picture similar to the ones I posted would be helpful.

Begginnerdev commented: Nice post! +8
TnTinMN 418 Practically a Master Poster

Perhaps something like this, where "ellispse1" in the name of the ellipse you defined in XAML.

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            Ellipse copyel = EllipseCloneProperties(ellipse1);
            // set your positioning properties
            canvas1.Children.Add(copyel);
        }
        private Ellipse EllipseCloneProperties(Ellipse source)
        {
            Ellipse clone = new Ellipse();

            foreach (System.Reflection.PropertyInfo pi in typeof(Ellipse).GetProperties())
            {
                if (pi.CanWrite && pi.CanRead)
                {
                    pi.SetValue(clone, pi.GetValue(source, null), null);
                }
            }

            return clone;
        }
TnTinMN 418 Practically a Master Poster

Sorry but that, I forgot a line of code to add the newrow to the table.

For Each r As DataRow In dataTable.Rows
   newrow = datatableAllString.NewRow
   For i As Int32 = 0 To datatableAllString.Columns.Count - 1
      newrow(i) = r.ItemArray(i).ToString()
   Next i
   datatableAllString.Rows.Add(newrow)
Next r
Gobble45 commented: Solution! +1
TnTinMN 418 Practically a Master Poster

This is not an ideal solution, but I think that it has the least chance of confusing you.

We will create a new datatable with only string values.

Dim fileName As New IO.FileInfo(frmStepOne.ofdFileSearch.FileName)
Dim connection As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=dBase IV;Data Source='" & fileName.DirectoryName & "'")
Dim tablename As String = fileName.Name.Substring(0, fileName.Name.Length - fileName.Extension.Length)
Dim command As New OleDb.OleDbCommand(tablename, connection)
command.CommandType = CommandType.TableDirect
Dim dataTable As New DataTable
connection.Open()
Dim reader As OleDb.OleDbDataReader = command.ExecuteReader
dataTable.Load(reader)
connection.Close()
connection.Dispose()
'---------------- 
Dim datatableAllString As New DataTable

For Each col As DataColumn In dataTable.Columns
   datatableAllString.Columns.Add(col.ColumnName, GetType(String))
Next
Dim newrow As DataRow
For Each r As DataRow In dataTable.Rows
   newrow = datatableAllString.NewRow
   For i As Int32 = 0 To datatableAllString.Columns.Count - 1
      newrow(i) = r.ItemArray(i).ToString()
   Next i
Next r
dataTable.Dispose()
'----------------
DataGridView1.DataSource = datatableAllString
TnTinMN 418 Practically a Master Poster

Here is an example that you can follow to read in the DBASE file. It is slightly different than the method you are using.

   Dim ofd As New OpenFileDialog
   With ofd
      .Filter = "DBASE File (*.dbf)|*.dbf"
      .Multiselect = False
      .CheckFileExists = True
   End With

   If ofd.ShowDialog() = Windows.Forms.DialogResult.OK Then
      Dim fi As New IO.FileInfo(ofd.FileName)

      Dim cn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=dBase IV;Data Source='" _
                                          & fi.DirectoryName & "'")
      Dim TableName As String = fi.Name.Substring(0, fi.Name.Length - fi.Extension.Length)
      Dim cmd As New OleDb.OleDbCommand(TableName, cn)
      cmd.CommandType = CommandType.TableDirect
      Dim dt As New DataTable
      cn.Open()
      Dim rdr As OleDb.OleDbDataReader = cmd.ExecuteReader
      dt.Load(rdr)
      DataGridView1.DataSource = dt
      cn.Close()
      cn.Dispose()
   End If
Gobble45 commented: This solution has fixed my issue! +0
TnTinMN 418 Practically a Master Poster

i know basics of java morderately well. will catching C# be easy given this ?

That is something that only you can decide after giving it a go. We all have different aptitudes. All I can say is that some refer to C# as Microsoft's answer to java, so it may seem familiar to you. However, I found that similiarities between two languages can lead to unrealistic expectations and frustration when the subject language does things differently.

Also, don't think that you are going to learn it all in a short period of time or at all. The .Net framework is huge and growing. Whatever .Net language you use is just a means to use the framework.

Personally, I try to not use language specific contructs as much as possible, but rather use the framework types and classes as much as possible. This makes it easier for me to move between VB and C#. Some would say that this is a poor style. Fashions change and if I am not being payed to produce code to someone's standard, who are they to tell me that I am doing to wrong. :)

seeing the code examples above , i guess i can write C# code in place of VB code , and still all will be well ? i think i remember seeing project options on the opening page of VS 2010... so if i want to code in C# or C++ or VB , ill just have …

TnTinMN 418 Practically a Master Poster

In addition to rubberman's comment:

you are summing in "coursesCount:, but comparing "courses".

Is this the logic you intended?

TnTinMN 418 Practically a Master Poster

You will likely get several techniques for doing this. Here are two that I find preferable.

Public Class Form1

   Sub LaunchForm2()
      Dim f2 As New Form2
      f2.needVariable = 2 ' pass as property
      f2.ShowDialog()
   End Sub
   Sub LaunchForm3()
      Dim f3 As New Form3(3) ' pass in constructor
      f3.ShowDialog()
   End Sub

   Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      LaunchForm2()
      LaunchForm3()
   End Sub
End Class

'Declare a property on the 2nd form

Public Class Form2
   Inherits Form

   Private _needVariable As Int32
   Public Property needVariable() As Int32
      Get
         Return _needVariable
      End Get
      Set(ByVal value As Int32)
         _needVariable = value
      End Set
   End Property 'needVariable

   Private Sub Form2_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
      MsgBox("F2: " & needVariable.ToString())
      Me.Close()
   End Sub
End Class

' pass the value in the form's constructor

Public Class Form3
   Inherits Form

   Private needVariable As Int32


   Public Sub New(ByVal needVariable As Int32)
      Me.needVariable = needVariable
   End Sub

   Private Sub Form2_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
      MsgBox("F3: " & needVariable.ToString())
      Me.Close()
   End Sub
End Class
Begginnerdev commented: Posted my post before reading your post! +0
TnTinMN 418 Practically a Master Poster

@TnTinMN: Way back, I did lots of VBA programming on Excel. I always found VB.NET some super VBA. When I first met C#, well, I was lost. Consise syntax, lambda expressions, predicate delegates, etc. etc. I'm sure you can do all those things in VB.NET, but it seems as if it always has to happen via some sort of workaround. But correct me if I'm wrong.

VB.Net is not a some form a super VBA. It is an entirely different language. Granted, it still maintains much of the same syntax structure of VB6 just like VB6 maintained a lot syntax structure of BASIC. However, Vb.Net is just that, it is a .Net language that after compiles to the same Common Intermediate Language that the C# compiler compiles to. Hence the ease of using a C# library in VB.Net or visa versa.

I am not sure extactly what you mean here by "workaround" and I don't want to invoke a preferred language war, but I see a lot of this as an issue of style, familiarity and personal preference.

C#'s syntax is concise because someone defined a shorthand notation versus a more verbose statement.

Let us take a simple example:

C#
delegate int del(int i);
static void Main(string[] args)
{
    del myDelegate = x => x * x;
    int j = myDelegate(5); //j = 25
}

VB
Delegate Function del(i As Integer) As Integer
Private Shared Sub Main(args As String())
     Dim myDelegate As del = Function(x) x * …
TnTinMN 418 Practically a Master Poster

Personally I prefer VB.Net.

If your goal is improve marketable skills in a few weeks and you already have a C background, it will be much easier for you to pick-up C#. Unfortonately, VB is viewed by many as an inferior language (even though it essentially equal to C#).

MS claims to be working on bringing parity to the two languages, but in my view this has primarily focused on adding functionality to C# that previously only existed in VB and not the other way around. C# is still their flagship .Net language and is/was used to write a the framework libraries.

Officially, VB6 is dead, but it is tenacious. MS updated the VBA language (VBA is essentially an interpreted form of VB6) in 2010, so there is some hope that they will recant their decision and release a VB7 at some point. Any effort to learn VB6 should be viewed as an effort to build up your skills repertoire. (I.E. it can not hurt to know it.) Old code will still need to be maintained and the VB6 runtime is supposed to be supported through the Windows 8 lifecycle.

ddanbe commented: Again, great answer. +14
TnTinMN 418 Practically a Master Poster

infor = false

I think that should be Info=false;

deceptikon commented: Good catch +12
TnTinMN 418 Practically a Master Poster

Hi ddanbe,

I'm glad you found a new toy to play with. :)

You may find these examples useful: Samples Environment for Microsoft Chart ControlsClick Here

The chart control was also made available for .Net 3.5 as a separate library.

Microsoft Chart Controls for Microsoft .NET Framework 3.5Click Here

ddanbe commented: A little late, but great advise! +14
TnTinMN 418 Practically a Master Poster

You should calculate the monthly payment once based on the initial loan amount and not in your loop based on remaining balance.

Are you using the Financial Class from the VisualBasic Namespace? If so, then your usage is incorrect and you should review the documentation.

ddanbe commented: Great answer +14
TnTinMN 418 Practically a Master Poster

You need to retrieve the command-line arguments, if any, and test the first argument. It should be the file that launched the application.

        Dim fi As IO.FileInfo ' used to test for file properties
        If My.Application.CommandLineArgs.Count > 0 Then
            fi = New IO.FileInfo(My.Application.CommandLineArgs(0))
            If fi.Exists Then
                Select Case fi.Extension.ToLower
                    Case ".fred"
                        ' do something with fred
                    Case ".wilma"
                        ' do something with wilma
                    Case Else
                        ' do something else
                End Select
            End If
        End If
TnTinMN 418 Practically a Master Poster

Zick,

You may need install the ACE provider on the other machine.

Microsoft Access Database Engine 2010 Redistributable

You will need to make sure which bitness (32-64, or both) that your application targets. Go to Project->Properties and select the compile tab.

At the top of the screen you should see two comboboxes.

The one on the left should be "Configuration" and the one on the right should be "Platform". Platform is the one of interest.

Please let us know what is selected for Platform.

TnTinMN 418 Practically a Master Poster

Don,

No offense intended, but you need to get more of the basics (no pun intended) under control first.

Learn to use the debugger. It is there for reason it and is your best friend.

Debugging User Interface Reference

Set a break-point in your code and inspect the variable's contents by hovering your mouse pointer over the variable name. This will allow you to see if the variables actually hold what you think they do.

You are using SQL Server, yet your code is using the OLEBD namespace data objects (connection, dataadapter, etc.). This in itself is not incorrect, but there is the SQLClient namespace that has versions of these objects specifically tailored to SQL Server.

Minor issue: you are hard coding your connection strings into your code. This will make it a pain later on when you want to distribute your application. You could define a string variable in Module or my preference is to use the My.Settings collection that VB provides. You can access this by going to Project Properties and selectioning the settings tab. When you define the setting, select "Connection string" for the type.

In the code you have shown, you are "opening" a connection. You should be close every connection you open. I believe the DataAdapter fill method does not require you top open the connection first. It will open and close the connection that you have provided it.

I also suggest that you consider using the DataSet designer to assist you in …

TnTinMN 418 Practically a Master Poster

But when i run the setup to install it in another computer which is a 64bit. My project didnt connect to the database which is access.

The most likely issue is that the target install can not find the DB provider.

If you are using the Jet provider, your application must be 32-bit as there is no 64-bit Jet provider.

If you are using the ACE provider, then make sure you have the correct (32 vs 64) installed to match your application's targeted CPU. see: http://msdn.microsoft.com/en-us/library/ff965871.aspx#DataProgrammingWithAccess2010_using32vs64ace

I believe that if you used the ANYCPU option, then it would JIT to a 64-bit application on a 64-bit OS.

Begginnerdev commented: Yeppers! +8
TnTinMN 418 Practically a Master Poster

PopulateGridView(.SelectedValue.ToString());

SelectedValue will be a DataRowView and not the Text displayed in the combobox.

Use: ((DataRowView)comboBox1.SelectedValue).Row["TABLE_NAME"].ToString()
or I guess you could just use comboBox1.Text.

Also, it would probably be a good idea to dispose of the datagridview data source before re-assigning it to a new DataTable.

        if (dataGridView1.DataSource != null && dataGridView1.DataSource is DataTable)
        {
            ((DataTable)dataGridView1.DataSource).Dispose();
        }
TnTinMN 418 Practically a Master Poster

Perhaps something like this will work for you.

Public Class Form1

   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      With ListView1
         .Alignment = ListViewAlignment.SnapToGrid
         .AllowDrop = True
         .AutoArrange = False
         .Scrollable = False
         .View = View.LargeIcon
      End With
   End Sub

   Private Sub ListView1_ItemDrag(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemDragEventArgs) Handles ListView1.ItemDrag
      Dim lvi As ListViewItem = CType(e.Item, ListViewItem)
      ListView1.DoDragDrop(New DataObject("System.Windows.Forms.ListViewItem", lvi), DragDropEffects.Move)
   End Sub

   Private Sub ListView1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListView1.DragEnter
      If e.Data.GetDataPresent("System.Windows.Forms.ListViewItem") Then
         e.Effect = DragDropEffects.Move
      End If
   End Sub

   Private Sub ListView1_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListView1.DragOver
      Dim lvi As ListViewItem = CType(e.Data.GetData("System.Windows.Forms.ListViewItem"), ListViewItem)
      Dim Offset As Size = Size.Subtract(Cursor.Size, New Size(Cursor.HotSpot.X, Cursor.HotSpot.Y))
      lvi.Position = Point.Subtract(ListView1.PointToClient(New Point(e.X, e.Y)), Offset)
      e.Effect = DragDropEffects.Move
   End Sub

End Class
TnTinMN 418 Practically a Master Poster

the secondary axis i want it to be fixed in the line of the primary axis in the left side

Assuming that this means that you want both axes to have the same range, then something like this will work.

  With Chart1
     ' Y1 = first Y Point, Y2 = Second Y point, etc.
     Dim ymin As Double = Math.Min(.Series(0).Points.FindMinByValue("Y1").YValues(0), _
                                   .Series(1).Points.FindMinByValue("Y1").YValues(0))

     Dim ymax As Double = Math.Max(.Series(0).Points.FindMinByValue("Y1").YValues(0), _
                                   .Series(1).Points.FindMinByValue("Y1").YValues(0))

     'round values to the nearest "Factor"
     Const Factor As Double = 5

     ymin = Math.Floor(ymin / Factor) * Factor
     ymax = Math.Ceiling(ymax / Factor) * Factor

     .ChartAreas(0).AxisY.Minimum = ymin
     .ChartAreas(0).AxisY.Maximum = ymax
     .ChartAreas(0).AxisY2.Minimum = ymin
     .ChartAreas(0).AxisY2.Maximum = ymax

  End With
Begginnerdev commented: I'm confuse. (DERP) +8
TnTinMN 418 Practically a Master Poster

Try something like this:

Public Class Form1

   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      Dim sorter As New lvMonthSorter
      sorter.MonthColumn = 0 ' set the column that holds the month
      sorter.Order = SortOrder.Ascending
      ListView1.ListViewItemSorter = sorter
   End Sub

End Class


Public Class lvMonthSorter

   Implements System.Collections.IComparer
   ' array to get a month index from for sorting
   Private Shared Months() As String = {"january", "february", "march", "april", "may", "june", _
                           "july", "august", "september", "october", "november", "december"}

   Private _MonthColumn As Int32 = 0
      Public Property MonthColumn() As Int32
      Set(ByVal Value As Int32)
         _MonthColumn = Value
      End Set

      Get
         Return _MonthColumn
      End Get
   End Property

   Private _Order As SortOrder = SortOrder.Ascending
   Public Property Order() As SortOrder
      Set(ByVal Value As SortOrder)
         _Order = Value
      End Set
      Get
         Return _Order
      End Get
   End Property

   Public Function Compare(ByVal x As Object, ByVal y As Object) As Int32 Implements IComparer.Compare
      Dim result As Int32

      Dim xstr As String = CType(x, ListViewItem).SubItems(_MonthColumn).Text.ToLower
      Dim ystr As String = CType(y, ListViewItem).SubItems(_MonthColumn).Text.ToLower

      Dim xpos As Int32 = Array.FindIndex(Of String)(Months, Function(xs As String) xs = xstr)
      Dim ypos As Int32 = Array.FindIndex(Of String)(Months, Function(ys As String) ys = ystr)

      result = xpos.CompareTo(ypos)

      Select Case Order
         Case SortOrder.Ascending : Return result
         Case SortOrder.Descending : Return -result
         Case Else : Return 0
      End Select
   End Function

End Class
ImZick commented: This work for me. +2
TnTinMN 418 Practically a Master Poster

Based on the fact that you currently have this working, It appears that the returned recordset for the first entered character is not to large to fit into the available memory.

The question is why are you querying the database for subsequently entered characters?

Load a datatable based on the first entered character and then use that table as the datasource for the listbox. On subsequent character entry, adjust the table's defaultview row filter.

Something like this:

   Private lbxSource As New DataTable
   Private LastLoadCharacter As Char = Nothing

   Private Sub tbSearchCriteria_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbSearchCriteria.TextChanged

      Dim txtlen As Int32 = tbSearchCriteria.Text.Length
      If txtlen = 0 Then
         ListBox1.DataSource = Nothing
      Else
         If txtlen = 1 Then

            If LastLoadCharacter <> tbSearchCriteria.Text(0) Then
               LastLoadCharacter = tbSearchCriteria.Text(0)
               ' query database and load the table lbxSource with the results
            End If
            lbxSource.DefaultView.RowFilter = ""
            ListBox1.DataSource = lbxSource

         Else
            lbxSource.DefaultView.RowFilter = "[SearchField] Like '" & tbSearchCriteria.Text & "*'"
         End If
      End If

   End Sub
TnTinMN 418 Practically a Master Poster

For future reference: SQL Server Data Type Mappings

TnTinMN 418 Practically a Master Poster

Sorry forgot C#,

object doNotSaveChanges = Word.WdSaveOptions.wdDoNotSaveChanges;
object missing =  System.Reflection.Missing.Value;
doc.Close(ref doNotSaveChanges, ref missing, ref missing);
ddanbe commented: top +14
TnTinMN 418 Practically a Master Poster

Don,

I had seen your prior post and decided to add some comments to the example that I had previouly provided. For once I refreshed my browser before posting it and seen that you have got it working. Good job!

Since you seen to be having problems with terminology (wat! you no speekee mi lingo!), I am going to post it anyways so that it may help you understand some of the jibberish. :)

Public Class Form1

   ' the following statement creates an instance of the class ControlTextSaver
   ' the constructor for the class (the "New" subroutine) expects a string that
   ' is the path to a file that will store the Text property for the specified controls
   Private controlTextManager As New ControlTextSaver("savedtb.txt")

   ' Form_Load is an event handler that runs after an instance of the form is created.
   ' the default configuration of VB.Net automatically creates the form instance for you.
   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

      ' the following for-next loop is an attempt to show you that you could add the controls to the 
      ' text manager in a loop, eventhough I do not agree with this methodology

      For i = 1 To 3 ' I an only using 3 texboxes for this example
         ' assuming that all the textboxes are parented to a panel
         ' the control manager exposes a List(of Controls) property
         ' since the is just like any other List(of type) instance, 
         ' you can add, insert, …
TnTinMN 418 Practically a Master Poster

Don,

I realized that I did not address the questions you raised in the following text.

...it is within a Panel that I'm using because it needs a vertical scroll bar. This suggests that I may need some other code for it to recognize the TextBox within the panel that IS on the form!! What tangled webs I weave!

Controls can parent other controls. You can make a control a child be another by adding it to the target parent control's Controls collection or by setting the Parent property of the child control.

parent.Controls.Add(child)

or

child.Parent = parent

If all the textboxes are parented to the panel, then you could change Me.Controls to Panel1.Controls (replace Panel1 with the true name of the panel) and your logic would function. "Me" is an internal reference to the class in which you are writing code; in this case the form you are defining. The reason you are able to type the name of the textbox reference and it is recognized by the IDE is because you have defined in the class even if you are not aware that you have done so.

When you drag a control to the design, visual studio executes a design routine for that control that generates the statements necessary to instaniate it and set its properties. This code is then written to the form's designer file. You can view this file by going to the solution explorer window and clicking on the …

TnTinMN 418 Practically a Master Poster

Don,

You are beginning to see the issues that I tried to cautioned you about in this post.

http://www.daniweb.com/software-development/vbnet/threads/449051/saving-multiple-strings-to-a-single-.txt-file-in-top-to-bottom-order#post1941747

Consider the time that you have wasted already just to trying and save some time typing in names of the controls that you wish to save the text from by using a loop to generate the control's name. Is it really worth it?

The class shown in that post will manage the saving and restoring of the Text property. All you need to do is create an instance of it and tell it which controls to manage and then issue it the commands for saving and loading the text at the proper point in your code.

TnTinMN 418 Practically a Master Poster

I'll answer and ask all at the same time: Are you sure that it is worth the effort?

Sorry, no offense intended, I just could not resist being a Smart aleck. Besides, I had to beat Michael to the punch line.

TnTinMN 418 Practically a Master Poster

Just to let you know, I am also pretty much self taught in programming and hold two engineering degrees. In fact, it was my distain for doing mundane computations that provided the impetus to become more proficient at programming.

It takes time to to develop skills whether they be in programming or anything else. Since you are still a student in engineering, you should be presented with plenty of well defined and tedious computational tasks that could be made easier with some type of computer program. Even if you don't end up being a full-time coder, having the skill will be only to your benefit. Keep your options open.

I would recommend that you use your elective classes wisely to strengthen skills that will be valuable to you as both an engineer or programmer. i.e. advanced mathemetics.

I am somewhat concerned that you have expressed doubt about your ability to tackle developing a large complex program. As an engineering student, you should realize that a well designed large complex system is built of many smaller components.

However, if you are in the midst of the weed-out class, I can understand that confidence may be shaken a bit at this point. Stick it out it will get better.

You may want to talk to your adviser and some other of your professors about your love for programming. You may even be able to pick-up some work develop applications for them.

It's hard to give more relevant advice, without knowing more about …

TnTinMN 418 Practically a Master Poster

I don't know.

But if you did, would they eat the nasty bugs like they do in my garden?

TnTinMN 418 Practically a Master Poster

neither, you are an unclosed tag name. now get noff the computer an do your homework!

if an idea is proclaimed to be half-baked, which half is ready for consumption?

TnTinMN 418 Practically a Master Poster

Oh boy blinky buttons! : )

Give this button a try:

Public Class FlashyButton
   Inherits Button
   Private WithEvents FlashTimer As New Timer

   Private _AlternateBackColor As Color = Color.Green
   Public Property AlternateBackColor() As Color
      Get
         Return _AlternateBackColor
      End Get
      Set(ByVal value As Color)
         _AlternateBackColor = value
      End Set
   End Property 'AlternateBackColor


   Private _FlashDuration As Int32 = 1000
   Public Property FlashDuration() As Int32
      Get
         Return _FlashDuration
      End Get
      Set(ByVal value As Int32)
         _FlashDuration = value
      End Set
   End Property 'FlashDuration

   Private _FlashEnabled As Boolean = True
   Public Property FlashEnabled() As Boolean
      Get
         Return _FlashEnabled
      End Get
      Set(ByVal value As Boolean)
         _FlashEnabled = value
      End Set
   End Property 'FlashEnabled

   Private ElapsedTime As Int32
   Private OrigBackColor As Color
   Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
      If FlashEnabled Then
         Enabled = False
         FlashTimer.Interval = 75
         ElapsedTime = 0
         OrigBackColor = Me.BackColor
         FlashTimer.Start()
      End If
      MyBase.OnClick(e)
   End Sub

   Private AltColorSet As Boolean

   Private Sub FlashTimer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles FlashTimer.Tick
      ElapsedTime += FlashTimer.Interval
      If ElapsedTime >= FlashDuration Then
         BackColor = OrigBackColor
         FlashTimer.Stop()
         Enabled = True
         Exit Sub
      Else
         If BackColor = OrigBackColor Then
            BackColor = AlternateBackColor
         Else
            BackColor = OrigBackColor
         End If
      End If
   End Sub
End Class

Just add to your project code as a new class and rebuild the project. You should then see it at the top of your toolbox.

TnTinMN 418 Practically a Master Poster

How come I can not print it?

Please show all your code.

TnTinMN 418 Practically a Master Poster

after this there existed a variable with the name and value as requested

This sounds like a key-value pair to me. Perhaps a Dictionary will work.

Begginnerdev commented: Dictionaries are a life saver. +0
TnTinMN 418 Practically a Master Poster

Hey, hey, hey — don't be mean. We don't have to be mean. 'Cause, remember: no matter where you go... there you are. --- Buckaroo Banzai

TnTinMN 418 Practically a Master Poster

You have mixed together various statements that are not necessarily related.

     ConnectionSettings() ' this does what?

     ' I assume that con is a MySqlConnection defined elsewhere
    ' don't need to open connect, the dataadapter will handle open/close
    'con.Open()

    Dim sql As String

    ' you do realize that this dataset will only exist in the context of this code block?
    Dim ds As New DataSet
    Dim da As MySqlDataAdapter

    Dim RowsNo As Integer ' purpose for this ?

    Dim cmd as New MySqlCommand()
    cmd.Connection = con

    sql = "SELECT * FROM tblStudents WHERE StudentID = @studentid"
    cmd.CommandText = sql
    cmd.Parameters.AddWithValue("@studentid", txtStudentID.Text)

    ' why this is here I have no clue
    'cmd.ExecuteNonQuery()

    ' feed the dataadapter the command
    dim da as New MySqlDataAdapter(cmd)

    ' use the adapter to create and fill the table Students
    da.Fill(ds, "Students")

    msgbox(ds("Students").Rows.count.ToString)
TnTinMN 418 Practically a Master Poster

So I take my favorite word and mix it with numbers, like:
b1u2l3l4s5h6i7t

I see into the future and Ene Uran's account has been hacked. :)

tux4life commented: :D +0
TnTinMN 418 Practically a Master Poster

I may be mistaken here, but under VB2010 Express you can use the ReportViewer control, however you will not have design time support for either the control nor the Report. The only way I have been able to make this work is to add the control to the Form via your own code.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    'ReportViewer1
    '
    ' place and size the control
    Me.ReportViewer1.Location = New System.Drawing.Point(10, 10)
    Me.ReportViewer1.Name = "ReportViewer1"
    Me.ReportViewer1.Size = New System.Drawing.Size(300, 200)
    Me.ReportViewer1.TabIndex = 0
    Me.ReportViewer1.Parent = Me

    ' the next line load the XML report file for the application directory.
    ' you can locate the file anywhere you wish, just adjust the path
    Me.ReportViewer1.LocalReport.ReportPath = ".\Report1.rdlc"

    ' tells the viewer to refresh with the currently loaded report
    Me.ReportViewer1.RefreshReport()

End Sub

Sample report definition file:

<?xml version="1.0" encoding="utf-8"?>
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
  <InteractiveHeight>11in</InteractiveHeight>
  <rd:DrawGrid>true</rd:DrawGrid>
  <InteractiveWidth>8.5in</InteractiveWidth>
  <rd:SnapToGrid>true</rd:SnapToGrid>
  <RightMargin>1in</RightMargin>
  <LeftMargin>1in</LeftMargin>
  <BottomMargin>1in</BottomMargin>
  <rd:ReportID>2ae1843f-1c7c-4caf-80ae-3fd92ba70b98</rd:ReportID>
  <Width>6.5in</Width>
  <Body>
    <ReportItems>
      <Textbox Name="textbox2">
        <rd:DefaultName>textbox2</rd:DefaultName>
        <Top>0.125in</Top>
        <Width>1.125in</Width>
        <Style>
          <PaddingLeft>2pt</PaddingLeft>
          <PaddingRight>2pt</PaddingRight>
          <PaddingTop>2pt</PaddingTop>
          <PaddingBottom>2pt</PaddingBottom>
        </Style>
        <CanGrow>true</CanGrow>
        <Left>0.25in</Left>
        <Height>0.375in</Height>
        <Value>hello</Value>
      </Textbox>
    </ReportItems>
    <Height>2in</Height>
    <Style>
      <BackgroundColor>LightGrey</BackgroundColor>
    </Style>
  </Body>
  <Language>en-US</Language>
  <TopMargin>1in</TopMargin>
</Report>
Begginnerdev commented: Nice example! +8
TnTinMN 418 Practically a Master Poster

Might as well take it the rest of the way and get the top 5 that the OP wants.

SELECT TOP 5 Count(ContactInfo.CustomerID) AS CustomerCount, ContactInfo.City
FROM ContactInfo
GROUP BY ContactInfo.City
ORDER BY Count(ContactInfo.CustomerID) DESC 

Note that this can return more than 5 records if multiple cities have the same count.

TnTinMN 418 Practically a Master Poster

This is your problem

Private Sub GetWord()
    Dim strWordList() As String = Split(My.Computer.FileSystem.ReadAllText("Words.txt"), vbCr)
    Dim randomGenerator As New Random
    intLine = randomGenerator.Next(0, 64144)
    strWord = strWordList(intLine).ToUpper
End Sub

You are splitting on VbCr. It should be VbCrLf

Or try:

Private Sub GetWord()
    Dim strWordList() As String = IO.File.ReadAllLines("Words.txt")
    Dim randomGenerator As New Random

    intLine = randomGenerator.Next(0, 64144)
    strWord = strWordList(intLine).ToUpper

End Sub

Also, instead of the loop: lblDisplayWord.Text = New String("-"c, strWord.Length)

TnTinMN 418 Practically a Master Poster

I got some funky behavior as well. Had two controls on the form and one of then tended to disappear.

I think it was related to you setting the FlatStyle in OnPaint. Changing styles tends to trigger a paint event on most controls.

I modified it as follows and all worked great.

//default constructor
    public BinarycheckBox() 
    {
     base.FlatStyle  =  FlatStyle.Flat; //needed
    }

    [System.ComponentModel.DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
    public new System.Windows.Forms.FlatStyle FlatStyle
    {
        get { return base.FlatStyle; }
        set { }
    }

    //we only need to override the OnPaint method 
    //we do our own painting here
    protected override void OnPaint(PaintEventArgs pevent)
    {
        base.OnPaint(pevent);   //needed
ddanbe commented: Looks great! I fact it was with FlatStyle I had troubles with! +14
TnTinMN 418 Practically a Master Poster

Hi ddanbe,

Fun little program. It reminded me how much fun I had drawing geometric shapes back in the dinosaur days when PC's were a curiousity to most.
It inspired me to see how much I have forgotten. :) It took a while but is finally gelled in my mind I was back in the groove with polar to cartesian transformations. If your interested, here is my attempt. It will draw multipointed stars.

TnTinMN 418 Practically a Master Poster
tux4life commented: Exactly! That is what the OP should have Googled himself in fact. +13