失败的“Hello World” [英] Failing on "Hello World"

查看:132
本文介绍了失败的“Hello World”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望这是对我如何进行设置的简单疏忽,因为这是我第一次运行VB,因为只安装VS社区2017(详见下文)。我创建了一个空白应用程序(通用Windows),向MainPage添加了一个按钮,然后双击
按钮来编辑事件处理代码。我的计划是显示一个简单的消息框,所以在新创建的子消息中,我开始输入"messagebox"。但当我到达"mes"时,Intellisense已经用完了想法并且 


错误 < span style ="font-size:0.75em; white-space:pre">
BC30451
'mes'未声明。由于其保护级别,它可能无法访问。


在我的错误列表中弹出。 


请告诉我这是什么简单... 


谢谢


吉米





Microsoft Visual Studio社区2017 
版本15.2(26430.4)发布

VisualStudio.15.Release / 15.2.0 + 26430.4

Microsoft .NET Framework

版本4.7.02046

解决方案

< blockquote>

嗨吉米!


在通用Windows应用程序中,Messagebox是MessageDialog。


这是代码(VB.NET)你'需要: 

导入Windows.UI.Popups 
导入Windows.UI.Xaml
导入Windows.UI.Xaml .Controls
Imports Windows.UI.Xaml.Navigation
Imports SDKTemplate

Partial Public NotInheritable Class CloseCommand
Inherits SDKTemplate.Common.LayoutAwarePage

'指针回来到主页面。如果你想在MainPage中调用方法,如
'作为NotifyUser()
私有rootPage As MainPage = MainPage.Current

Public Sub New()
Me.InitializeComponent()
End Sub

Private Async Sub CloseCommandLaunch_Click(sender As Object,e As RoutedEventArgs)
'创建消息对话框并设置其内容和标题
Dim messageDialog = New MessageDialog("未找到互联网连接。")

'添加按钮并设置回调
messageDialog.Commands.Add(New UICommand(" Try)再次","Sub(命令)
rootPage.NotifyUser(""& command.Label&"'按钮已被选中。",_
NotifyType.StatusMessage)
End Sub))

messageDialog.Commands.Add(New UICommand(" Close",Sub(command)
rootPage.NotifyUser("''' &安培;命令.Label& "'按钮已被选中。",_
NotifyType.StatusMessage)
结束子))

'设置默认调用的命令
messageDialog.DefaultCommandIndex = 0

'设置按下转义时调用的命令
messageDialog.CancelCommandIndex = 1

'显示消息对话框
Await messageDialog.ShowAsync
End Sub
End Class


您可以在这里找到更多信息:< a href ="https://docs.microsoft.com/en-us/uwp/api/windows.ui.popups.messagedialog">  https://docs.microsoft.com/en-us/uwp/api /windows.ui.popups.messagedialog



希望它有用。



如果它对你有好处,你能否将这个答案标记为你的问题的答案?



在Twitter上关注我:  https://twitter.com/NordineMhoumadi



Hopefully this is a simple oversight in how I've set things up, because this is the first time I've run VB since just installing VS Community 2017 (per details below). I created a Blank App (Universal Windows), added a button to MainPage and double-clicked the button to edit the event handling code. My plan was to display a simple messagebox so in the newly created sub I began typing "messagebox" but by the time I got to "mes", Intellisense had run out of ideas and 

Error BC30451 'mes' is not declared. It may be inaccessible due to its protection level.

popped up in my error list. 

Please tell me it's something simple... 

Thanks

Jimmy


Microsoft Visual Studio Community 2017 
Version 15.2 (26430.4) Release
VisualStudio.15.Release/15.2.0+26430.4
Microsoft .NET Framework
Version 4.7.02046

解决方案

Hi Jimmy !

In the Universal Windows application Messagebox is MessageDialog.

Here is the code (VB.NET) you'll need : 

Imports Windows.UI.Popups
Imports Windows.UI.Xaml
Imports Windows.UI.Xaml.Controls
Imports Windows.UI.Xaml.Navigation
Imports SDKTemplate

Partial Public NotInheritable Class CloseCommand
    Inherits SDKTemplate.Common.LayoutAwarePage

    ' A pointer back to the main page.  This is needed if you want to call methods in MainPage such
    ' as NotifyUser()
    Private rootPage As MainPage = MainPage.Current

    Public Sub New()
        Me.InitializeComponent()
    End Sub

    Private Async Sub CloseCommandLaunch_Click(sender As Object, e As RoutedEventArgs)
        ' Create the message dialog and set its content and title
        Dim messageDialog = New MessageDialog("No internet connection has been found.")

        ' Add buttons and set their callbacks
        messageDialog.Commands.Add(New UICommand("Try again", Sub(command)
            rootPage.NotifyUser("The '" & command.Label & "' button has been selected.", _ 
                NotifyType.StatusMessage)
                                                              End Sub))

        messageDialog.Commands.Add(New UICommand("Close", Sub(command) 
            rootPage.NotifyUser("The '" & command.Label & "' button has been selected.", _
                NotifyType.StatusMessage)
                                                          End Sub))

        ' Set the command that will be invoked by default
        messageDialog.DefaultCommandIndex = 0

        ' Set the command to be invoked when escape is pressed
        messageDialog.CancelCommandIndex = 1

        ' Show the message dialog
        Await messageDialog.ShowAsync
    End Sub
End Class

You'll find more informations here : https://docs.microsoft.com/en-us/uwp/api/windows.ui.popups.messagedialog

Hope it wil be useful.

If it's good for you, can you mark this answer as answer of your question please?

Follow me on twitter : https://twitter.com/NordineMhoumadi


这篇关于失败的“Hello World”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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