如果是字符串并显示消息框 [英] if string and showing message box

查看:100
本文介绍了如果是字符串并显示消息框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
我有一个名为"myLine"的字符串
我想做一个"myLine"是否为"Model:iPhone2,1"的操作,然后显示一个带有"am devoloper"或"No"按钮的消息框
请给我代码(帮助我知道),以帮助您,或者仅将我重定向到正确的位置.
非常感谢Advance

Hi all
i am having a string called "myLine"
I want to do an if "myLine" is "Model: iPhone2,1" then show a message box with buttons "am a devoloper" or "No"
please help by giving me the code (know that am greedy) or only redirect me to the right place.
Thanks in Advance

推荐答案

严重吗?您不能独自提出吗?

Seriously? You couldn''t come up with this on your own?

string msg = (myLine == "Model: iPhone2,1")?"am developer":"no";
MessageBox.Show(msg);



我会留给您根据您选择的框架进行调整(因为您未指定).



编辑===============

这是非常基本的东西.如果您不忙于查看是否有人回答了您的问题,那么您现在可能已经解决了.你当程序员多久了?



I''ll leave it to you to adjust for your framework of choice (since you didn''t specify).



EDIT ===============

This is VERY basic stuff. You could have solved it by now if you weren''t so busy seeing if anyone answered your question. How long have you been a programmer?

CString msg = (myLine == "Model: iPhone2,1")?"am developer":"no";
AfxMessageBox(msg);



我4年来没有做过C ++,因此,如果您需要更多帮助,就可以依靠自己,除非别人认为适合尝试帮助您.



I haven''t done C++ in over 4 years, so if you need more help, you''re on your own unless someone else sees fit to try to help you.


开始在文档中寻找答案. String类是您将要使用的最常见的类之一,因此您应该阅读文档并至少了解回答此类简单问题的基本方法.我已经在其他问题之一中为您提供了StringBuilder的链接,因此您应该可以从那里访问String.
Make a start at looking for answers in the documentation. The String class is one of the most common ones that you will use so you should read the documentation and at least know the basic methods to answer simple questions like this. I have already given you the link for StringBuilder in one of your other questions, so you should be able to get to String from there.


尝试以下操作:
如果Model = iPhone1或iPhone2,则

elseif myLine = Model然后
MessageBox.Show(是开发人员",是/否)
endif

它可能并不完美,但是您可以尝试.
普拉萨德:-D
Try this:
if Model = iPhone1 or iPhone2 then

elseif myLine = Model then
MessageBox.Show("am a developer",Yes/No)
endif

it might not be perfect but you can try it.
Prasad :-D


这篇关于如果是字符串并显示消息框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆