Results 1 to 18 of 18

Thread: showing data retrieved in a msgbox

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2004
    Location
    Ohio. United States of America
    Posts
    96

    Resolved showing data retrieved in a msgbox

    I need to show data that has been retrieved in a msgbox:

    here is my code:

    Try
    tempCardNum = ds.Tables("cardInfo").Rows(0).Item("cardNum")
    MsgBox("Card Found, The Details: " & cardNum & ", MsgBoxStyle.Critical")
    Catch ex1 As Exception
    MsgBox("Card Not Found - Any Problems Please Contact Your System Administrator")
    End Try


    where & cardNum & is, i need to show card number, but i also need to show date scanned...

    not sure how to go about this...

    thanks in advance
    Last edited by escapegirl; Oct 13th, 2004 at 05:45 AM.

  2. #2
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Is your tempCarNum getting set to the data that you want? If so, use that variable. If you need to retrieve other information, use the same technique.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2004
    Location
    Ohio. United States of America
    Posts
    96

    yes...

    yes the tempcardnum does give the info i want, i am not sure how to actually add it to the line of code...

    do i need the & tempcardnum & in there???

    this is that part that is confusing the hell out of me hehehe...


  4. #4
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Something like this
    VB Code:
    1. Dim tempCardNum As String = "Hello escapegirl"
    2.         MsgBox("Card Found, The Details: " & tempCardNum, MsgBoxStyle.Critical)

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 2004
    Location
    Ohio. United States of America
    Posts
    96

    thanks

    thanks, what if i need three fields to show?

    would it be seperated by comma's or &?

    thanx

  6. #6
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    You need to concatenate you strings, so the ampersand. You could do like this
    VB Code:
    1. Dim field1 As String = "Hello"
    2.         Dim field2 As String = "there"
    3.         Dim field3 As String = "escapegirl"
    4.         MsgBox("Card Found, The Details: " & field1 & " " & field2 & " " & field3, MsgBoxStyle.Critical)
    But that gets a little ugly to look at. You might want to do the same thing a different way, such as:
    VB Code:
    1. Dim field1 As String = "Hello"
    2.         Dim field2 As String = "there"
    3.         Dim field3 As String = "escapegirl"
    4.         Dim message As String = "Card Found, The Details: " & field1 & " " & field2 & " " & field3
    5.         MsgBox(message, MsgBoxStyle.Critical)

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Aug 2004
    Location
    Ohio. United States of America
    Posts
    96

    mmmm not sure

    would the above work if i was pulling the information from a database.

    some history...

    i am pulling 3 fields from a db - giftcard
    i search on cardNum (select * where cardNum blah blah blah)

    the three fields that come up are:

    cardNum
    assocID
    dateScanned

    this is the line of code i have for the above:

    MySql1String = "select * from cardInfo where cardNum = '" & txbxGiftCardNumSearch.Text & "' "


    Try

    tempCardNum = ds.Tables("cardInfo").Rows(0).Item("cardNum")


    MsgBox("Card Found, The Details: " & *********

    Catch ex1 As Exception

    MsgBox("Card Not Found - Any Problems Please Contact Your System Administrator")

    End Try


    where the * are is the point at which i need to pull the above fields. the above fields do store in tempcardnum...

    hope this makes more sense...

    any ideas???



  8. #8
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416
    VB Code:
    1. messagebox.show("Card Found, The Details: " & tempCardNum")

    or you could use a datareader if want to query in the database.

    VB Code:
    1. 'lets assume that the first column of your table is cardNum
    2. 'cn is a connection
    3. dim cm as new sqlcommand("select * from cardInfo where cardNum = '" & txbxGiftCardNumSearch.Text & "' ",cn)
    4. dim dr as sqldatareader = cm.executereader
    5. while dr.read
    6.      messagebox.show("Card Found, The Details:" & dr(0).tostring)
    7. end while
    8. dr.close

  9. #9
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Whatever you want to do will work, don't ask, just try it. I hope you realize that in your code when you set tempCardNum, you're setting it to the value of a particular column in a particular row. Just do the same for any info you want to retrieve. Or do the same thing differently, it doesn't really matter.
    Try?, try not. Do, or do not. There is no try.
    Oh, and do a favor please. Please learn how to format your code. It will help anyone reading it, and it will help you to get good responses.

    Mike

  10. #10
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416
    mike just calm down your getting burn. Maybe his really a stupid newbie..

    me too...i accept that im also a stupid newbie..

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Aug 2004
    Location
    Ohio. United States of America
    Posts
    96

    sorry...

    Sorry about the formatting - i sometimes get carried away with the left align hehehehe

    anyways,

    i know that i am setting the tempCardNum as a particular value of a particular row - that was my intention.

    i need all of the information from that row - but throughout my program i want to be specific at different times.

    in essence... i was to learn how to say

    just pick these 2 columns, or pick all three.

    i just want to know how to add more than one column of information to a message box...?


    i have been messing with it - and what looks right - does not work...



  12. #12

    Thread Starter
    Lively Member
    Join Date
    Aug 2004
    Location
    Ohio. United States of America
    Posts
    96

    Arrow yeah MiKe

    i am a newbie ...

    4 weeks in fact...

    give me a break...


  13. #13
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Apologies, I did not mean any offense.

  14. #14
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416
    ^ escapegirl

    does the code given to you work?

    it seems mike and I given you the exact code you want..

  15. #15

    Thread Starter
    Lively Member
    Join Date
    Aug 2004
    Location
    Ohio. United States of America
    Posts
    96

    i know hehehe

    its okay, i know...

    can you answer my question tho???


  16. #16
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: i know hehehe

    Originally posted by escapegirl
    its okay, i know...

    can you answer my question tho???

    Yes, just concatenate the string in the Messagebox's show function:

    VB Code:
    1. messagebox.show("Card Found, The Details:" & dr(0).tostring & " The secret:" & dr(1).ToString) 'and so on

  17. #17

    Thread Starter
    Lively Member
    Join Date
    Aug 2004
    Location
    Ohio. United States of America
    Posts
    96

    Got it to work - Thanks

    I got the code to work... It took a little manipulation, but thank god and you guys/gals it works...

    Thanx

    *** If you can't explain it simply, you don't understand it well enough ***

  18. #18
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Got it to work - Thanks

    Originally posted by escapegirl
    thank god and you guys/gals
    No need to thank me twice.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width