473,386 Members | 1,754 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

messagebox code not working

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
Jul 21 '05 #1
8 1290
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" <an*******@discussions.microsoft.com> wrote in message
news:4A**********************************@microsof t.com...
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)

Jul 21 '05 #2
Bhavna wrote:
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.
Jul 21 '05 #3
Cor
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
Jul 21 '05 #4
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
Jul 21 '05 #5
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

Jul 21 '05 #6
Cor
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
Jul 21 '05 #7
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?

Jul 21 '05 #8
Cor
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.
I want this message to appear if the user tries to make the same booking

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


Jul 21 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Rich Tasker | last post by:
I have a strange situation. A simple call to MessageBox.Show("XXX", "YYY") does not display the message in the messagebox with a visible font. Based on the content of the messagebox, the box...
10
by: Russ | last post by:
I've been trying to figure out how to show a simple messagebox with an OK button in my web client program (C#). I have looked at every reference to JScript and MessageBox that seemed even remotely...
4
by: Larry Woods | last post by:
I have a Messagebox that looks like: MessageBox.Show("There are pending changes for this patient. Do you want to continue to close?", "Pending Changes", MessageBoxButtons.YesNo,...
3
by: Kiyomi | last post by:
Hello, I use in my application MessageBox.Show and it works perfectly when I run this application on my local computer (http://localhost). When I diployed this application on the server,...
3
by: puckkid12 | last post by:
Hello guys, Just to note off, i've spent the last 3 years working in Visual Basics, so I have these really bad habbits in c++ right now, heh, however I'm working on it. Right I have the real...
3
by: rdemyan via AccessMonster.com | last post by:
Sometimes users (including myself) accidentally click on the application close icon in the application menu bar when they meant to just click on the 'X' for the form. Of course the app closes and...
3
by: Luis Alvarado | last post by:
Hello everybody, I am new programming in asp.net, recently I have been hired in a company and they were creating a simple application, this application is developed in asp.net 2 visual Studio 2005...
6
by: Goran Djuranovic | last post by:
Hi all, I have a VB.NET windows application that uses MDI form. When I try to delete a datagrid row from one of the MDI children forms, I use a MessageBox YesNo confirmation, which, after confirmed,...
9
by: sovht | last post by:
System: Intel, Windows XP Pro, SP2 IDE: VC++ 6.0 Problem: *Very* simple program to create a MessageBox only ever displays the first character of the given string. I checked the spec for the...
2
by: alexbisson | last post by:
Hi, I'm working on a WinForm application with .NET CF 2.0 and I have a background running thread that needs to notify the user about various events. The problem is that everytime I want to notify...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.