messagebox code not working

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I am using a messabge box to show a message containing varibles and values from controls

the problem i have is that the values for variable1 and combobox1.selectedvalue do not seem to show up in my message. The date seems to work fine however (dtpDate.value). Can anyone see what im doin wrong

Dim myMessage As Strin
myMessage = "The " & varible1 & " for " & ComboBox1.SelectedValue & " has already been chosen for the " & dtpDate.Value & ". Please change your selection

MessageBox.Show(myMessage
 
Bhavna said:
Hi,

I am using a messabge box to show a message containing varibles and
values from controls.

the problem i have is that the values for variable1 and
combobox1.selectedvalue do not seem to show up in my message. The
date seems to work fine however (dtpDate.value). Can anyone see what
im doin wrong?

Dim myMessage As String
myMessage = "The " & varible1 & " for " & ComboBox1.SelectedValue & "
has already been chosen for the " & dtpDate.Value & ". Please change
your selection"

MessageBox.Show(myMessage)

Have you properly set the ValueMember for the ComboBox? Have you insured
that something is selected? Possibly SelectedItem will get you closer to
what you really want? I can't comment on why variable1 is not appearing in
the string, assuming it's not the misspelling in your message, as you don't
show where that is defined or initialized.
--
Tom Porterfield
MS-MVP MCE
http://support.telop.org

Please post all follow-ups to the newsgroup only.
 
First off, Turn On Option Strict, this code shoudn't even compile ;-).
Before you call myMessage, use a Debug.WriteLine(varible1) and
Debug.WriteLine(CType(Combobox1.SelectedValue, String)), I'm guessing those
values are empty. ALso, you may want to use Ctype(ComboBox1.SelectedItem,
String) instead...

HTH,

Bill
Bhavna said:
Hi,

I am using a messabge box to show a message containing varibles and values from controls.

the problem i have is that the values for variable1 and
combobox1.selectedvalue do not seem to show up in my message. The date seems
to work fine however (dtpDate.value). Can anyone see what im doin wrong?
Dim myMessage As String
myMessage = "The " & varible1 & " for " & ComboBox1.SelectedValue & " has
already been chosen for the " & dtpDate.Value & ". Please change your
selection"
 
Hi Bhavna,

As alternative to Bill,

You can also do to look what is with those variables first
messagebox.show(variable1)
messagebox.show(combobox1.selectedValue.tostring)

Cor
 
Hi Bill,

I thought that I have seen often in this newsgroup people who do not use
VS.net but are making programs direct using the compiler.

To let you know why I did make this extra message.

Cor
 
Hello cor

The variable shows as empty and the application falls over when trying to display the second combobox value

i dont know why this is the case. I am displaying the values in a 'catch' part of a try-catch statement. Could this be the problem

Here is part of the code that contains the problem..

Catch ex As Exceptio
Dim session As Strin
If CBoxSession.SelectedText = "A" The
session = "Afternoon
ElseIf CBoxSession.SelectedText = "M" The
session = "Morning
ElseIf CBoxSession.SelectedText = "E" The
session = "Evening
End I

Dim myMessage As Strin
myMessage = "The " & session & " session for the " & CBoxRoomNames.SelectedItem & " has already been booked for the " & dtpRoomDate.Value & ". Please change your selection

MessageBox.Show(myMessage
End Tr
 
Hi Bhavna,

This does not to be in a catch block, it means that your code is always
going wrong.
(probably it goes terrible slow)

Sent the code before this (from the try block), I will see if I can have a
look at it.

Cor
 
Hello Cor

I want this message to appear if the user tries to make the same booking again. If they do make the same booking, isnt the catch part of the statemnt invoked with a message that states that the primary key needs to be unique?

I want this message to appear instaed of the default message that is displayed in the 'catch' part as this would be meaningless to the user

Will this still work if i put my code in the 'try' part?
 
Hello Bhavna,

The catch part is only for something that is really unpredictable by you in
your program.

That can be by instance the power of a server goes down or/and in a multi
user environment another user did something in the same time with the data
while you where busy that you could not know before.
again.

So this can be the right place.
But tha this should be a booking made by another user in the time that this
user did make the booking however by instance, he needed time to talk with
the client.

If the user has made this booking in this session while it was a not a free
reservation when he started, than it is not the way to go. Also not when he
did made the reservation twice in the same session, that is all trapable by
your program itself.

Just my thought about this.

Cor
 
Back
Top