10 Replies - 1552 Views - Last Post: 27 May 2013 - 05:02 AM Rate Topic: -----

#1 SyntaxMan  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 10
  • Joined: 26-May 13

Need some visual basic help. New here.

Posted 26 May 2013 - 04:09 AM

Note: If this is in the wrong place, Mods please move. Also tell me where you'll move it because I am a noob to this forum.

I am a full time college student majoring in Computer Information Systems and Accounting. I need some help with this Visual Basic problem. I did not know where to post this but I saw student so I thought I could get some help. I only have until midnight for this one problem and it is bugging me. It really is quite discouraging. I'd email my teacher but he takes like 4 days to respond to his emails. Last time I emailed him, I got the "help" I needed 2 days after the assignment was due. I don't want to email my oher classmates because I do not want to feel like the "dumb one". I very rarely ask for help and I am due for some.


The objective is to modify a shipping hub to be able to run a LINQ on the package selected. I want to add all the information I find into a string called packageInfo. I also want to display that information in a message box using a message box show function.

This is my current code:

 handles ListBox's DoubleClick event
   Private Sub packagesListBox_DoubleClick(sender As Object,
      e As System.EventArgs) Handles packagesListBox.DoubleClick
        Dim tempPackage As Package 'Step D Create a reference of package
        Dim packageInfo As String 'Step D Create a String to store the information about the given package

        Dim numberSelect As Integer ' Step e creating a integer that stores the number selected in the List Box

        numberSelect = packagesListBox.SelectedIndex ' Step e creating a integer that stores the number selected in the List Box
        ' Step e. Creating a LINQ query that selests from list the Package with the Packagenumber that's selected in ListBox
        Dim PackageNumberQuery = From p In list
                                 Where (p.PackageNumber = numberSelect)
                                 Select p
        ' Step f. If...Then statement to check if the number selected is a valid item. 
        If packagesListBox.SelectedIndex = -1 Then
            MessageBox.Show("Please select a valid package number", _
                            "Important Message")
        End If
        ' Step g. Assign to tempPackage the first element of the query
        For Each tempPackage In list
            packageInfo = String.Concat(tempPackage)
        Next
        'Step H Create an else statement to notify user if an invalid item has been selected from the ListBox
        If Not packagesListBox.SelectedIndex = -1 Then
            MessageBox.Show(packageInfo)  
        Else
            MessageBox.Show("Error. Please select valid number")
        End If

    End Sub ' packagesListBox_DoubleClick


I'm pretty new at this whole visual basic thing and I don't know if it is the actual coding or the book that is confusing me. I have been working on this thing since Tuesday. (Already finished my other assignment and it's working perfectly). Am I missing a very simple issue?

Is This A Good Question/Topic? 0
  • +

Replies To: Need some visual basic help. New here.

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8364
  • View blog
  • Posts: 31,073
  • Joined: 12-June 08

Re: Need some visual basic help. New here.

Posted 26 May 2013 - 06:58 AM

Moving to VB.NET


Quote

Am I missing a very simple issue?

I don't know, are you? You never explained your problem or question.
Was This Post Helpful? 0
  • +
  • -

#3 JackOfAllTrades  Icon User is online

  • Saucy!
  • member icon

Reputation: 5951
  • View blog
  • Posts: 23,210
  • Joined: 23-August 08

Re: Need some visual basic help. New here.

Posted 26 May 2013 - 08:44 AM

You haven't stated what the problem is exactly. That is, are you receiving errors when compiling or running? If so, state them (copy and paste if it's when building) here. Or is the problem that the output is not what you expect? If that is the case, you need to tell us what you receive versus what you expect. We are not mind readers and we are not standing over your shoulder watching you, so you have to be the eyes here.
Was This Post Helpful? 0
  • +
  • -

#4 SyntaxMan  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 10
  • Joined: 26-May 13

Re: Need some visual basic help. New here.

Posted 26 May 2013 - 02:32 PM

My goal is to store the information of the package which includes address, state, etc. I then need it be able to display that in a message box using a MessageBox.Show.

My problem is that when I double click an invalid package number i.e a blank space, it brings up the error message I want.

I basically need it to display the contents of the list in a messagebox under the name packageInfo.

Does that help to explain it?

My goal is to get it functional by midnight.

To note: I am not asking for answers, I am asking for a little push to get me going in the right direction. I don't know how to add information to a String.

I also don't know how to display that information. I am a VB Noob.
Was This Post Helpful? 0
  • +
  • -

#5 JackOfAllTrades  Icon User is online

  • Saucy!
  • member icon

Reputation: 5951
  • View blog
  • Posts: 23,210
  • Joined: 23-August 08

Re: Need some visual basic help. New here.

Posted 26 May 2013 - 02:41 PM

Well you don't seem to be using the results of your query. Maybe you want to use that instead of list here?

For Each tempPackage In list
    packageInfo = String.Concat(tempPackage)
Next


You also wouldn't want to execute that iteration if your the selection was invalid right? Because you are regardless of the validity of the selection.

Quote

I don't know how to add information to a String.


Using the StringBuilder class
Was This Post Helpful? 0
  • +
  • -

#6 SyntaxMan  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 10
  • Joined: 26-May 13

Re: Need some visual basic help. New here.

Posted 26 May 2013 - 03:08 PM

View PostJackOfAllTrades, on 26 May 2013 - 02:41 PM, said:

Well you don't seem to be using the results of your query. Maybe you want to use that instead of list here?

For Each tempPackage In list
    packageInfo = String.Concat(tempPackage)
Next


You also wouldn't want to execute that iteration if your the selection was invalid right? Because you are regardless of the validity of the selection.

Quote

I don't know how to add information to a String.


Using the StringBuilder class



What would it look like corrected? I do better of visual rather than verbal. Thank you for replying though.
Was This Post Helpful? -1
  • +
  • -

#7 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8364
  • View blog
  • Posts: 31,073
  • Joined: 12-June 08

Re: Need some visual basic help. New here.

Posted 26 May 2013 - 03:20 PM

View PostSyntaxMan, on 26 May 2013 - 04:32 PM, said:

... snip ...
To note: I am not asking for answers, I am asking for a little push to get me going in the right direction.
... snip ...


View PostSyntaxMan, on 26 May 2013 - 05:08 PM, said:

... snip ...

What would it look like corrected? I do better of visual rather than verbal. Thank you for replying though.



Come on, try a little! See what shakes down!
Was This Post Helpful? 0
  • +
  • -

#8 SyntaxMan  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 10
  • Joined: 26-May 13

Re: Need some visual basic help. New here.

Posted 26 May 2013 - 03:45 PM

Okay I changed list to packageNumberQiery.

For Each tempPackage In PackageNumberQuery
            packageInfo = String.Concat(tempPackage)
        Next
        'Step H Create an else statement to notify user if an invalid item has been selected from the ListBox
        If Not packagesListBox.SelectedIndex = -1 Then
            MessageBox.Show(packageInfo)
        Else
            MessageBox.Show("Error. Please select valid number")
        End If


It says " Warning 1 Variable 'packageInfo' is used before it has been assigned a value. A null reference exception could result at runtime."

I would do stringbuilder but we have not learned that yet in the class and instructions do nto say to use it. Grr

Is the String.Concat adding the information to the packageInfo string? The messagebox stuff works but it is empty.
Was This Post Helpful? 0
  • +
  • -

#9 SyntaxMan  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 10
  • Joined: 26-May 13

Re: Need some visual basic help. New here.

Posted 26 May 2013 - 04:29 PM

Hate to ask but could you help me solve this? Like walk me through what needs to be done. The message box works but comes up empty. Is my String.Concat function right?
Was This Post Helpful? 0
  • +
  • -

#10 SyntaxMan  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 10
  • Joined: 26-May 13

Re: Need some visual basic help. New here.

Posted 26 May 2013 - 06:00 PM

Grr it is getting closer to due date and I still can't get this darn thing to work right. Any tips?
Was This Post Helpful? 0
  • +
  • -

#11 JackOfAllTrades  Icon User is online

  • Saucy!
  • member icon

Reputation: 5951
  • View blog
  • Posts: 23,210
  • Joined: 23-August 08

Re: Need some visual basic help. New here.

Posted 27 May 2013 - 05:02 AM

Quote

To note: I am not asking for answers, I am asking for a little push to get me going in the right direction. I don't know how to add information to a String.


Quote

What would it look like corrected? I do better of visual rather than verbal. Thank you for replying though.


Hi-frigging-larious.

I gave you a push, you barely moved. Looks to me like you were really looking less for a push, and more for someone to pick you up and carry you to the finish line.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1