473,569 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.selec tedvalue 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.Selec tedValue & " has already been chosen for the " & dtpDate.Value & ". Please change your selection

MessageBox.Show (myMessage
Jul 21 '05 #1
8 1296
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(Combobox 1.SelectedValue , String)), I'm guessing those
values are empty. ALso, you may want to use Ctype(ComboBox1 .SelectedItem,
String) instead...

HTH,

Bill
"Bhavna" <an*******@disc ussions.microso ft.com> wrote in message
news:4A******** *************** ***********@mic rosoft.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.selec tedvalue 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.Selec tedValue & " 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.selec tedvalue 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.Selec tedValue & "
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.sele ctedValue.tostr ing)

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.Sel ectedText = "A" The
session = "Afternoon
ElseIf CBoxSession.Sel ectedText = "M" The
session = "Morning
ElseIf CBoxSession.Sel ectedText = "E" The
session = "Evening
End I

Dim myMessage As Strin
myMessage = "The " & session & " session for the " & CBoxRoomNames.S electedItem & " has already been booked for the " & dtpRoomDate.Val ue & ". 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
541
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 sizes properly so I know there is a message in there. I also found a keyboard shortcut where <ctrl>+<insert> will copy the contents of the messagebox...
10
2333
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 like it could help, both in the VS help and in this NG. I found lots of examples of people saying how easy it is and showing examples, and...
4
1994
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, MessageBoxIcon.Question) When I execute the Messagebox.Show, then press either 'Yes' or 'No' I get 25 of the following Messageboxes: "incorrect syntax near the...
3
2678
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, however, it does not work. It does not give me even an error message, but the screen is just freezed (it is running open the page). What are the...
3
7722
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 down basic question, when someone clicks on a button I want a messagebox to appear on the screen. My current code has this
3
4142
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 this is very annoying. So, I added a messagebox to my hidden StartAppForm in the Unload event. Now when the application closes the user is...
3
4031
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 and is tested in a Windows 2003 standard. My problem is that when I check some buttons events, they are calling a Msgbox function, I have read that...
6
3480
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, minimizes the MDI form. Why is this happening and how can I prevent it? Important thing to say is, if I use just "OK" MessageBox, it DOES NOT...
9
7961
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 MessageBox function and I believe I am adhering to it. I have also done a search for this issue, but have come up empty handed. Perhaps my search...
2
1755
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 the user with a MessageBox about an event, the application exits once the messagebox is displayed...I get the following message in the output window:...
0
7701
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8130
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3643
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
940
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.