none
I would like to input multiple values for example -x, -y, -z and have an output of text that I have setup RRS feed

  • Question

  •  I would like to input multiple values for example -x, -y, -z and have an output of text that I have setup that equals the certain values using visual basic

    Essentially convert the input values to a predetermined output text x y goes in fix and scan come out


    • Edited by Temery357 Thursday, October 5, 2017 9:52 PM
    Thursday, October 5, 2017 9:52 PM

Answers

  • Hi Frank,

    So I have setup what I am trying to do 

    

    Public Class Form1
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            If TextBox1.Text = "-N" Then
                TextBox2.Text = "Images are stacked"
    
            End If
            If TextBox1.Text = "-Jd" Then
                TextBox2.Text = "Images are compressed"
            End If
    
            If TextBox1.Text = "-d" Then
                TextBox2.Text = "Remove the orginal file after succesful operation"
            End If
    
       
    End Class
    Now in this case what if I want to have multiple inputs so I can combine -N and -Jd and have the output be images and stacked and images are compressed?  Still trying :) hope your not too frustrated yet

    I don't understand what you're program is or what you're doing, but we need to start with a template (a class) and a collection of the objects which are created from that template.

    Does that make sense?


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    • Marked as answer by Temery357 Wednesday, October 18, 2017 11:27 PM
    Tuesday, October 10, 2017 9:47 PM
  • Now in this case what if I want to have multiple inputs so I can combine -N and -Jd and have the output be images and stacked and images are compressed?

    If you do it like that it will be almost impossible to process combined IDs.   It would need to look something like this:

    Public Class Form1
    
        Public IdStrings As New Dictionary(Of String, String)
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            IdStrings.Add("N", "Images come over stacked")
            IdStrings.Add("Jd", "images come over compressed")
            IdStrings.Add("SubCompact", "Subcompact")
            ' and so on
        End Sub
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim IDLIst() As String = TextBox1.Text.Split("-"c)
            For Each S As String In IDLIst
                If IdStrings.Keys.Contains(S) Then
                    TextBox2.AppendText(IdStrings(S) & vbCrLf)
                End If
            Next
        End Sub
    End Class

    Notice that adding the entries one line at a time in code is quite impractical.  You need to start by deciding what the source of your data is going to be. Once you decide that, getting it into the dictionary should be quite straightforward.

    You have not indicated how you can 'have multiple input'.  I have assumed that each input is identified by a starting '-' character.  This means that 'Sub-Compact' cannot be used as an ID, because it appears to be two ids '-Sub' and '-Compact'.  That's why it is important to set out the format and validation rules for your data before starting to code.

    You haven't indicated how you want to display the result.  I have assumed each item appears on a new line in the text box.  That should be easily adjustable to your required format.

    • Marked as answer by Temery357 Wednesday, October 18, 2017 11:23 PM
    Tuesday, October 10, 2017 10:05 PM
  • Right now I put in n and images come over stacked comes out.  If I enter n and jd I just get images come over stacked and images come over compressed.

    The dictionary is nothing to do with the combining - the dictionary is how you associate each ID with its corresponding string.  But, of course, without an effective means of doing that, then it becomes impossible to combine IDs.  A dictionary is one of many ways you could do that - it just happens to be built in and easily accessible.

    "I have assumed that each input is identified by a starting '-' character".   That's why the ID can't have an embedded '-'.  For instance, you would enter '-N-Jd" and you would get

            Images come over stacked
            
    images come over compressed

    You need to decide if that's how you want to do it. 

    • Edited by Acamar Wednesday, October 11, 2017 11:08 PM fmt
    • Marked as answer by Temery357 Wednesday, October 18, 2017 11:23 PM
    Wednesday, October 11, 2017 11:03 PM

All replies

  •  I would like to input multiple values for example -x, -y, -z and have an output of text that I have setup that equals the certain values using visual basic

    Essentially convert the input values to a predetermined output text x y goes in fix and scan come out


    Are you asking how to do this?

    If so, the best way depends a lot on the data - how much and what type - but a starting point would be to create a class and use a collection (like a generic list) of that class.

    Set up a method to return the value from the collection where those conditions are met (if one exists for that combination of x, y, and z).

    Is that what you're asking or did I miss it entirely?

    ***** EDIT *****

    As a follow-up, this might be confusing since you're seeing it out of context, but something like this is what I mean. It's a method in a class that I set up as an example a few years ago:

        Public Shared Function GetInstance(ByVal categoryName As String, _
                                           ByVal manufacturerName As String, _
                                           ByVal modelName As String, _
                                           ByVal doors As DoorType, _
                                           ByVal color As CarColor) As Car
    
            Dim retVal As Car = Nothing
    
            Try
                If String.IsNullOrWhiteSpace(modelName) Then
                    Throw New ArgumentException("The car model cannot be null or empty.")
    
                Else
                    Select Case categoryName
                        Case "Full-Size"
                            categoryName = "FullSize"
    
                        Case "Mid-Size"
                            categoryName = "MidSize"
    
                        Case "Sub-Compact"
                            categoryName = "Subcompact"
                    End Select
    
                    Dim models() As String = GetCarModels(categoryName, manufacturerName)
    
                    If models IsNot Nothing AndAlso models.Length > 0 Then
                        Dim category As CarCategory = _
                            DirectCast([Enum].Parse(GetType(CarCategory), categoryName), CarCategory)
    
                        Dim mfgr As CarManufacturer = _
                            DirectCast([Enum].Parse(GetType(CarManufacturer), manufacturerName), CarManufacturer)
    
                        Dim tempList As New List(Of Car)
                        Initialize(tempList)
    
                        If tempList IsNot Nothing AndAlso tempList.Count > 0 Then
                            Dim qry As System.Collections.Generic.IEnumerable(Of Car) = _
                                From c As Car In tempList _
                                    Where c.Category = category AndAlso _
                                        c.Manufacturer = mfgr AndAlso _
                                            c.Model.ToLower.Replace(" "c, "") = modelName.ToLower.Replace(" "c, "") AndAlso _
                                                c.Doors = doors AndAlso _
                                                    c.Color = color
    
                            If qry IsNot Nothing AndAlso qry.Count = 1 Then
                                retVal = qry.First
                            End If
                        End If
                    End If
                End If
    
            Catch ex As Exception
                Throw
            End Try
    
            Return retVal
    
        End Function


    "A problem well stated is a problem half solved.” - Charles F. Kettering


    Thursday, October 5, 2017 10:03 PM
  • Hi Frank,

    I think this definitely puts me on the right track, thank you for replying

    Thursday, October 5, 2017 10:29 PM
  • Hi Frank,

    I think this definitely puts me on the right track, thank you for replying

    You're welcome. :)

    If you want to get more specific then I'll help you set it all up (if you want).


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Thursday, October 5, 2017 10:32 PM
  • That would be great! So I want to create an executable where I input for example A and then I click a button and the text that is associated with A outputs in readable text.  The project Im working on is to take multiple values and input them into an executable program and have it output the text.  Another example would be I put in A, B and C and the out put would be this is what happens when a, b and c are applied.  I hope I am being clear enough :) 
    Thursday, October 5, 2017 11:17 PM
  • I hope I am being clear enough :) 

    Sure - you're probably talking about method overloading (maybe not but that sounds like what you mean).

    I'll help you with all of this, including persisting to file if you want - tomorrow though as it's late here now.

    Can you give me something more to go on though?

    A, B, C ... what they? Strings?

    Where does the data come from? Is it to be self-initialized or just what?

    Give me something more to work with here and I'll set it up or if you're still a bit unclear about what you mean then I'll try to put an example together that might give you some ideas.

    ***** EDIT *****

    I should have read that before I posted it, but this statement from Microsoft Docs isn't wrong, but it's incomplete:

    "Overloading is the creation of more than one procedure, instance constructor, or property in a class with the same name but different argument types."

    That's true but overloading comes to this: Change the signature. You can do that by changing the types (like the article shows), or by changing the number of arguments too - and that last way is what I think you mean.


    "A problem well stated is a problem half solved.” - Charles F. Kettering


    Thursday, October 5, 2017 11:25 PM
  • Essentially convert the input values to a predetermined output text x y goes in fix and scan come out

    How is this text pre-determined?  Is it in the code of the program, or is it stored in a file that you are providing (where does that file come from?) or is it going to be in a database (how is the database being maintained?) or is it coming from somewhere else?

    How is a particular text value associated to it's pre-determined output text?

    Thursday, October 5, 2017 11:31 PM
  • Hi Acamar,

    Im going to store it in a basic text file for the input strings I dont know if Im saying this right

    Thursday, October 5, 2017 11:36 PM
  • Im going to store it in a basic text file for the input strings I dont know if Im saying this right

    You can, or we can explore other ways that might be more appropriate.

    Given that then, you'll need an "initializer" method or will all of the data come from the users?

    Explain more about what you're actually doing and I think it'll make more sense.


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Thursday, October 5, 2017 11:40 PM
  • Awesome Frank, thank you!

    Im thinking if I have the data read from a text file with all the different strings in that text file and have them output to a text file with the associated strings

    So the program reads the A from the text file and it says hey Im reading an A so Im going to output text that says "this image is stacked" 

    Thanks again :) 

    Thursday, October 5, 2017 11:41 PM
  • Awesome Frank, thank you!

    Im thinking if I have the data read from a text file with all the different strings in that text file and have them output to a text file with the associated strings

    So the program reads the A from the text file and it says hey Im reading an A so Im going to output text that says "this image is stacked" 

    Thanks again :) 


    I'll look at it tomorrow (U.S. CDT) but can you give me some examples about what the "input" would be and what the resultant "output" would be please?

    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Thursday, October 5, 2017 11:44 PM
  • So the program reads the A from the text file and it says hey Im reading an A so Im going to output text that says "this image is stacked" 

    Then you will start with a definition of the structure of that text file.  In particular you need to decide how you associate "A" with a particular piece of text.  For instance:
      A,This is the text for A

    will allow you to split the line at the comma, so that you know what the text for "A" is.  So you need to ask yourself questions like "Will the text consists of multiple lines?, Could it have an embedded comma?, What will the ids look like (eg, A-Z, or any combination)? Is id "A" the same as id "a"?, and so on.

    Thursday, October 5, 2017 11:46 PM
  • Input=-N 

    Output=images will come over stacked

    Input= -Jd

    Output= images will come over compressed

    In referencing your code I didnt see until now if I am reading it correctly

     Try
                If String.IsNullOrWhiteSpace(modelName) Then
                    Throw New ArgumentException("The car model cannot be null or empty.")
    
                Else
                    Select Case categoryName
                        Case "-N"
                            categoryName = "Images come over stacked"
    
                        Case "-Jd"
                            categoryName = "images come over compressed"
    
                        Case "Sub-Compact"
                            categoryName = "Subcompact"
                    End Select

    Thursday, October 5, 2017 11:49 PM
  • Input=-N 

    Output=images will come over stacked

    Input= -Jd

    Output= images will come over compressed

    In referencing your code I didnt see until now if I am reading it correctly

     Try
                If String.IsNullOrWhiteSpace(modelName) Then
                    Throw New ArgumentException("The car model cannot be null or empty.")
    
                Else
                    Select Case categoryName
                        Case "-N"
                            categoryName = "Images come over stacked"
    
                        Case "-Jd"
                            categoryName = "images come over compressed"
    
                        Case "Sub-Compact"
                            categoryName = "Subcompact"
                    End Select

    For something like you've just described, a simple initializer method and a Select Case might be all you need.

    If you have a key (one single value or reference type, unique) then maybe a generic Dictionary might be helpful here. If you have multiple input parameters though, let's go ahead and set up a class and do it all from there with overloading so that it's more straightforward.

    Make sense?


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Thursday, October 5, 2017 11:55 PM
  • Input=-N 
    Output=images will come over stacked

    Input= -Jd
    Output= images will come over compressed

    You are not ready to start writing code until you have determined what the source of the data is going to be.  You need to consider where your information is coming from, how it is formatted, what are the rules are about the data content etc before you can start writing code to process it.

    Thursday, October 5, 2017 11:57 PM
  • That would be great! So I want to create an executable where I input for example A and then I click a button and the text that is associated with A outputs in readable text.  The project Im working on is to take multiple values and input them into an executable program and have it output the text.  Another example would be I put in A, B and C and the out put would be this is what happens when a, b and c are applied.  I hope I am being clear enough :) 

    We're all guessing at what your data is, where it's coming from and other details, but to get the conversation going again, the following is another possible approach.

    It uses a class, but the class really isn't doing much; the work behind this is a DataTable which that class creates. It also creates a BindingSource, bound to that DataTable.

    I set it up this way so that you can try it there and it'll work. If you'll please start a new project and on the form, add a BindingNavigator ("BindingNavigator1"), a DataGridView ("DataGridView1"), and four buttons:

    "btn_GetData"
    "btn_Filter1"
    "btn_Filter2"
    "btn_Filter3"

    I have mine set up like this:

    If you'll put those controls on your form and name them like I just showed then everything else will be done in code. It will get some fake data (but it looks real) that I have on my website - specifically this:

    http://www.fls-online.net/VBNet_Forum/SampleData/Sample_Data_10000.xml

    The DataGridView will populate with all 10,000 of those people's information and the three filter buttons will whittle the list down. The first one will filter the data for the state name being "Wisconsin". The second one will filter it down further where the state name is "Wisconsin" and the city name is "Avalon". Lastly, the third one whittles it down the same and also includes a filter for the name containing "Ashley".

    It's actually not as tough as it might sound. Go to code view in yours, delete everything and replace it with the following:

    Option Strict On
    Option Explicit On
    Option Infer Off
    
    Public Class Form1
        Private _people As New List(Of PersonData)
    
        Private Sub _
            Form1_Load(sender As System.Object, _
                       e As System.EventArgs) _
                       Handles MyBase.Load
    
            btn_Filter1.Enabled = False
            btn_Filter2.Enabled = False
            btn_Filter3.Enabled = False
    
            DGVSetup()
            PopulateDGV()
    
        End Sub
    
        Private Sub DGVSetup()
    
            With DataGridView1
                .AllowUserToAddRows = False
                .AllowUserToDeleteRows = False
                .AllowUserToOrderColumns = False
                .AllowUserToResizeRows = False
                .AlternatingRowsDefaultCellStyle.BackColor = Color.Aquamarine
                .ReadOnly = True
                .SelectionMode = DataGridViewSelectionMode.FullRowSelect
                .MultiSelect = False
                .RowHeadersVisible = False
                .RowTemplate.Height = 50
                .EnableHeadersVisualStyles = False
    
                With .ColumnHeadersDefaultCellStyle
                    .Font = New Font("Tahoma", 9, FontStyle.Bold)
                    .BackColor = Color.LightGreen
                    .WrapMode = DataGridViewTriState.True
                    .Alignment = DataGridViewContentAlignment.MiddleCenter
                End With
    
                .ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing
                .ColumnHeadersHeight = 50
                .DataSource = Nothing
                .Enabled = False
            End With
    
        End Sub
    
        Private Sub PopulateDGV(Optional ByVal bs As BindingSource = Nothing)
    
            With BindingNavigator1
                .BindingSource = Nothing
                .Enabled = False
            End With
    
            With DataGridView1
                .DataSource = Nothing
                .Enabled = False
            End With
    
            If bs IsNot Nothing Then
                With DataGridView1
                    .SuspendLayout()
    
                    .DataSource = bs
    
                    With .Columns(0)
                        .Width = 120
                        .DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft
                    End With
    
                    With .Columns(1)
                        .Width = 150
                        .DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
                    End With
    
                    With .Columns(2)
                        .Width = 100
                        .DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
                    End With
    
                    With .Columns(3)
                        .Width = 100
                        .DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
                    End With
    
                    With .Columns(4)
                        .Width = 100
                        .DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
                    End With
    
                    With .Columns(5)
                        If DataGridView1.Width > Me.Width Then
                            .AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
                        Else
                            .Width = 120
                        End If
    
                        .DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
                    End With
    
                    .ResumeLayout()
                    .Enabled = True
    
                    If .RowCount > 0 Then
                        .Rows(0).Selected = True
                    End If
                End With
    
                With BindingNavigator1
                    .BindingSource = bs
                    .Enabled = True
                End With
            End If
    
        End Sub
    
        Private Sub _
            btn_GetData_Click(sender As System.Object, _
                              e As System.EventArgs) _
                              Handles btn_GetData.Click
    
            btn_GetData.Enabled = False
    
            With Me
                .Cursor = Cursors.WaitCursor
                .Refresh()
            End With
    
            PersonData.GetPersonData(_people)
    
            PopulateDGV(PersonData.GetBindingSource(_people))
    
        End Sub
    
        Private Sub _
            btn_Filter1_Click(sender As System.Object, _
                              e As System.EventArgs) _
                              Handles btn_Filter1.Click
    
            ' Filter for the state name being "Wisconsin":
    
            Dim bs As BindingSource = PersonData.GetBindingSource(_people)
    
            If bs IsNot Nothing Then
                bs.Filter = "State = 'Wisconsin'"
                PopulateDGV(bs)
            End If
    
        End Sub
    
        Private Sub _
            btn_Filter2_Click(sender As System.Object, _
                              e As System.EventArgs) _
                              Handles btn_Filter2.Click
    
            ' Filter for the state name being "Wisconsin" and 
            ' the City being "Avalon":
    
            Dim bs As BindingSource = PersonData.GetBindingSource(_people)
    
            If bs IsNot Nothing Then
                bs.Filter = "State = 'Wisconsin' And City = 'Avalon'"
                PopulateDGV(bs)
            End If
    
        End Sub
    
        Private Sub _
            btn_Filter3_Click(sender As System.Object, _
                              e As System.EventArgs) _
                              Handles btn_Filter3.Click
    
            ' Filter for the state name being "Wisconsin" and 
            ' the City being "Avalon" and the person's name 
            ' containing "Ashley":
    
            Dim bs As BindingSource = PersonData.GetBindingSource(_people)
    
            If bs IsNot Nothing Then
                bs.Filter = "State = 'Wisconsin' And City = 'Avalon' And Name Like '*Ashley*'"
                PopulateDGV(bs)
            End If
    
        End Sub
    
        Private Sub _
            DataGridView1_DataBindingComplete(sender As Object, _
                                              e As System.Windows.Forms.DataGridViewBindingCompleteEventArgs) _
                                              Handles DataGridView1.DataBindingComplete
    
            Me.Cursor = Cursors.Default
            btn_GetData.Enabled = True
            btn_Filter1.Enabled = True
            btn_Filter2.Enabled = True
            btn_Filter3.Enabled = True
    
        End Sub
    End Class
    
    
    
    
    Public Class PersonData
        Private _firstName As String
        Private _middleInitial As String
        Private _lastName As String
        Private _streetAddress As String
        Private _city As String
        Private _state As String
        Private _zipCode As String
        Private _email As String
    
        Public Shared Sub _
            GetPersonData(ByVal list As List(Of PersonData))
    
            If list IsNot Nothing Then
                With list
                    .Clear()
                    .TrimExcess()
                End With
    
                InitializeData("http://www.fls-online.net/VBNet_Forum/SampleData/Sample_Data_10000.xml", list)
            End If
    
        End Sub
    
        Public Shared Function _
            GetBindingSource(ByVal list As List(Of PersonData)) As BindingSource
    
            Dim retVal As BindingSource = Nothing
    
            Dim dt As DataTable = GetDataTable(list)
    
            If dt IsNot Nothing Then
                retVal = New BindingSource _
                    With {.DataSource = dt}
            End If
    
            Return retVal
    
        End Function
    
        Private Sub New(ByVal firstName As String, _
                        ByVal middleInitial As String, _
                        ByVal lastName As String, _
                        ByVal streetAddress As String, _
                        ByVal city As String, _
                        ByVal state As String, _
                        ByVal zipCode As String, _
                        ByVal email As String)
    
            _firstName = firstName.Trim
            _middleInitial = middleInitial.Trim
            _lastName = lastName.Trim
            _streetAddress = streetAddress.Trim
            _city = city.Trim
            _state = state.Trim
            _zipCode = zipCode.Trim
            _email = email.Trim
    
        End Sub
    
        Private Shared Sub _
            InitializeData(ByVal url As String, _
                           ByVal personList As List(Of PersonData))
    
            If Not String.IsNullOrWhiteSpace(url) Then
                If personList IsNot Nothing Then
                    Dim xDoc As XElement = XElement.Load(url)
    
                    For Each info As XElement In xDoc...<Person>
                        personList.Add(New PersonData(info...<FirstName>.Value, _
                                                      info...<MiddleInitial>.Value, _
                                                      info...<LastName>.Value, _
                                                      info...<StreetAddress>.Value, _
                                                      info...<CityName>.Value, _
                                                      info...<StateName>.Value, _
                                                      info...<ZipCode>.Value, _
                                                      info...<EmailAddress>.Value))
                    Next
                End If
            End If
    
        End Sub
    
        Private Shared Function _
            GetDataTable(ByVal list As List(Of PersonData)) As DataTable
    
            Dim retVal As DataTable = Nothing
    
            If list IsNot Nothing Then
                Dim dt As New DataTable
                Dim column As New DataColumn
    
                With column
                    .DataType = System.Type.GetType("System.String")
                    .ColumnName = "Name"
                    dt.Columns.Add(column)
                End With
    
                column = New DataColumn
    
                With column
                    .DataType = System.Type.GetType("System.String")
                    .ColumnName = "Address"
                    dt.Columns.Add(column)
                End With
    
                column = New DataColumn
    
                With column
                    .DataType = System.Type.GetType("System.String")
                    .ColumnName = "City"
                    dt.Columns.Add(column)
                End With
    
                column = New DataColumn
    
                With column
                    .DataType = System.Type.GetType("System.String")
                    .ColumnName = "State"
                    dt.Columns.Add(column)
                End With
    
                column = New DataColumn
    
                With column
                    .DataType = System.Type.GetType("System.String")
                    .ColumnName = "Zip Code"
                    dt.Columns.Add(column)
                End With
    
                column = New DataColumn
    
                With column
                    .DataType = System.Type.GetType("System.String")
                    .ColumnName = "E-mail Address"
                    dt.Columns.Add(column)
                End With
    
                Dim row As DataRow
    
                For Each pd As PersonData In list
                    row = dt.NewRow
    
                    row("Name") = String.Format("{0} {1} {2}", pd.FirstName, pd.MiddleInitial, pd.LastName)
                    row("Address") = pd.StreetAddress
                    row("City") = pd.City
                    row("State") = pd.State
                    row("Zip Code") = pd.ZipCode
                    row("E-mail Address") = pd.Email
    
                    dt.Rows.Add(row)
                Next
    
                retVal = dt
            End If
    
            Return retVal
    
        End Function
    
        Public ReadOnly Property City As String
            Get
                Return _city
            End Get
        End Property
    
        Public ReadOnly Property Email As String
            Get
                Return _email
            End Get
        End Property
    
        Public ReadOnly Property FirstName As String
            Get
                Return _firstName
            End Get
        End Property
    
        Public ReadOnly Property LastName As String
            Get
                Return _lastName
            End Get
        End Property
    
        Public ReadOnly Property MiddleInitial As String
            Get
                Return _middleInitial
            End Get
        End Property
    
        Public ReadOnly Property State As String
            Get
                Return _state
            End Get
        End Property
    
        Public ReadOnly Property StreetAddress As String
            Get
                Return _streetAddress
            End Get
        End Property
    
        Public ReadOnly Property ZipCode As String
            Get
                Return _zipCode
            End Get
        End Property
    End Class

    This is how it will look when you run it:

    When you click the button to get the data, be patient as it'll take a few seconds to retrieve and populate the DGV:

    Once populated, now the DataGridView shows the data, the BindingNavigator shows the count of 10,000, and the three filter buttons are enabled:

    I'll step through the three filters following. Each time I filter is, please note the count shown in the BindingNavigator:

    So maybe that's something that you might consider. Please let me know what you think. :)


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Friday, October 6, 2017 1:19 PM
  • It does make sense, I am thinking this should be very simple, you have all given me a ton of good information.  In a form I am trying to build I will try to explain how it all should work see below think of it as a form

    text box here where I enter A or a combo of a b c                              text box over here that shows what the combo of a or a b and c does in this instance for example stack images, compress images

    execute button to click on to run the program here

    I am currently travelling for work but I will check this thread again and our over what has been said

    Also I just saw your form setup below I will set up that project because I def think I can make that work.  Sorry Im just a nube here, they didnt teach this at Cisco thats for sure lol

    You are a stand up guy Frank, thank you for you help :) and thank you to everyone here

    Friday, October 6, 2017 2:35 PM
  • I may be able to make this work but I think its much more complex then it needs to be for me.  All very good stuff though.   I have pasted my above response here as well Thanks again good sir

    Question
    You cannot vote on your own post
    0

    It does make sense, I am thinking this should be very simple, you have all given me a ton of good information.  In a form I am trying to build I will try to explain how it all should work see below think of it as a form

    text box here where I enter A or a combo of a b c                              text box over here that shows what the combo of a or a b and c does in this instance for example stack images, compress images

    execute button to click on to run the program here

    I am currently travelling for work but I will check this thread again and our over what has been said

    Also I just saw your form setup below I will set up that project because I def think I can make that work.  Sorry Im just a nube here, they didnt teach this at Cisco thats for sure lol

    You are a stand up guy Frank, thank you for you help :) and thank you to everyone here

    Friday, October 6, 2017 2:39 PM
  • Temery,

    I'm not following what you're trying to do at all, but try the example and if nothing else, maybe you can use it further down the road.


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Friday, October 6, 2017 2:42 PM
  • Hi Frank,

    So I have setup what I am trying to do 

    

    Public Class Form1
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            If TextBox1.Text = "-N" Then
                TextBox2.Text = "Images are stacked"
    
            End If
            If TextBox1.Text = "-Jd" Then
                TextBox2.Text = "Images are compressed"
            End If
    
            If TextBox1.Text = "-d" Then
                TextBox2.Text = "Remove the orginal file after succesful operation"
            End If
    
       
    End Class
    
    Now in this case what if I want to have multiple inputs so I can combine -N and -Jd and have the output be images and stacked and images are compressed?  Still trying :) hope your not too frustrated yet

    Tuesday, October 10, 2017 9:43 PM
  • Hi Frank,

    So I have setup what I am trying to do 

    

    Public Class Form1
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            If TextBox1.Text = "-N" Then
                TextBox2.Text = "Images are stacked"
    
            End If
            If TextBox1.Text = "-Jd" Then
                TextBox2.Text = "Images are compressed"
            End If
    
            If TextBox1.Text = "-d" Then
                TextBox2.Text = "Remove the orginal file after succesful operation"
            End If
    
       
    End Class
    Now in this case what if I want to have multiple inputs so I can combine -N and -Jd and have the output be images and stacked and images are compressed?  Still trying :) hope your not too frustrated yet

    I don't understand what you're program is or what you're doing, but we need to start with a template (a class) and a collection of the objects which are created from that template.

    Does that make sense?


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    • Marked as answer by Temery357 Wednesday, October 18, 2017 11:27 PM
    Tuesday, October 10, 2017 9:47 PM
  • Now in this case what if I want to have multiple inputs so I can combine -N and -Jd and have the output be images and stacked and images are compressed?

    If you do it like that it will be almost impossible to process combined IDs.   It would need to look something like this:

    Public Class Form1
    
        Public IdStrings As New Dictionary(Of String, String)
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            IdStrings.Add("N", "Images come over stacked")
            IdStrings.Add("Jd", "images come over compressed")
            IdStrings.Add("SubCompact", "Subcompact")
            ' and so on
        End Sub
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim IDLIst() As String = TextBox1.Text.Split("-"c)
            For Each S As String In IDLIst
                If IdStrings.Keys.Contains(S) Then
                    TextBox2.AppendText(IdStrings(S) & vbCrLf)
                End If
            Next
        End Sub
    End Class

    Notice that adding the entries one line at a time in code is quite impractical.  You need to start by deciding what the source of your data is going to be. Once you decide that, getting it into the dictionary should be quite straightforward.

    You have not indicated how you can 'have multiple input'.  I have assumed that each input is identified by a starting '-' character.  This means that 'Sub-Compact' cannot be used as an ID, because it appears to be two ids '-Sub' and '-Compact'.  That's why it is important to set out the format and validation rules for your data before starting to code.

    You haven't indicated how you want to display the result.  I have assumed each item appears on a new line in the text box.  That should be easily adjustable to your required format.

    • Marked as answer by Temery357 Wednesday, October 18, 2017 11:23 PM
    Tuesday, October 10, 2017 10:05 PM
  • Hi Acamar,

    What you gave me looks exactly how I want it to.  It looks like I need to create a dictionary so that I can combine string IDs to get a resultant output string. Right now I put in n and images come over stacked comes out.  If I enter n and jd I just get images come over stacked and images come over compressed. I need to play around with this andfigure out how to combine the ID strings in the input textbox and have them come out in the output textbox with the results.  Im going to give the dictionary a try and see what happens, thank you

    Wednesday, October 11, 2017 9:56 PM
  • Right now I put in n and images come over stacked comes out.  If I enter n and jd I just get images come over stacked and images come over compressed.

    The dictionary is nothing to do with the combining - the dictionary is how you associate each ID with its corresponding string.  But, of course, without an effective means of doing that, then it becomes impossible to combine IDs.  A dictionary is one of many ways you could do that - it just happens to be built in and easily accessible.

    "I have assumed that each input is identified by a starting '-' character".   That's why the ID can't have an embedded '-'.  For instance, you would enter '-N-Jd" and you would get

            Images come over stacked
            
    images come over compressed

    You need to decide if that's how you want to do it. 

    • Edited by Acamar Wednesday, October 11, 2017 11:08 PM fmt
    • Marked as answer by Temery357 Wednesday, October 18, 2017 11:23 PM
    Wednesday, October 11, 2017 11:03 PM
  • Yes I need to have the "-" character because thats how the syntax is laid out for the import arguments for our program here

    So yes I would enter -N-Jd and get the resultant images come over stacked images come over compressed.

    So I need the dictionary to combine ids or no? Because I like how you have it setup and it works but I just need to combine the strings.  I dont care that I would have to enter all the different strings one by one

    Thursday, October 12, 2017 5:28 PM
  • I understand you need to put it in "" for the -n and -jd 
    Thursday, October 12, 2017 9:41 PM
  • correction add to the existing dictionary
    Thursday, October 12, 2017 9:58 PM
  • Yes I need to have the "-" character because thats how the syntax is laid out for the import arguments for our program here

    Just because it exists in the input data doesn't mean you need to keep it.   Once the IDs and strings are in the dictionary then whether they retain the '-' is arbitrary.  I have assumed you have chosen not to retain it.

    So yes I would enter -N-Jd and get the resultant images come over stacked images come over compressed.

    Then the code I provided will work, as long as none of the IDs includes an embedded '-'.

    So I need the dictionary to combine ids or no? Because I like how you have it setup and it works but I just need to combine the strings.

    The code I provided accepts combined IDs in the form '-aaa-bbb-ccc' and combines the associated strings.  You don't need a dictionary to do that - it is one of many different possibilities.  The point is that the series of IF statements in the code you posted will be very difficult to implement for combined IDs, while a dictionary makes it easy.

    I dont care that I would have to enter all the different strings one by one

    If you are going to enter the different strings one by one then do it one time in a text file, and read it into the program to create the dictionary.  Maintaining it as string literals within the code is just too difficult.

    Friday, October 13, 2017 7:16 AM
  • I understand you need to put it in "" for the -n and -jd 
    I have no idea what you mean by this.  The code I provided doesn't include any additional "".
    Friday, October 13, 2017 7:17 AM
  • Awesome, thanks Acamar I think Im good to go!  Thanks everyone!! so helpful
    Monday, October 16, 2017 1:25 PM
  • Awesome, thanks Acamar I think Im good to go!  Thanks everyone!! so helpful
    If any of the above responses have been helpful in allowing you to solve the problem then they should be marked as answers.
    • Marked as answer by Temery357 Wednesday, October 18, 2017 11:22 PM
    • Unmarked as answer by Temery357 Wednesday, October 18, 2017 11:23 PM
    Monday, October 16, 2017 7:41 PM

  • Hi Temery357,

    As Acamar suggested,  It would be appreciated if you could close the thread by marking  helpful posts as an answer. This will help other members to find the solution quickly if they have faced the similar issue.


    Best Regards,

    Yohann Lu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Temery357 Wednesday, October 18, 2017 11:23 PM
    • Unmarked as answer by Temery357 Wednesday, October 18, 2017 11:23 PM
    Tuesday, October 17, 2017 2:14 AM
    Moderator