Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / ASP.NET [игнор отключен] [закрыт для гостей] / VB.NET How-To Try, Catch, Finally / 3 сообщений из 3, страница 1 из 1
12.09.2006, 16:37
    #33981614
BrokenPot
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
VB.NET How-To Try, Catch, Finally
Скачал 101 пример по VB.NET. Среди прочих - сабж.

Не могу запустить: ругается
Код: plaintext
Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated.
Не нравится ему DialogResult.Yes

Может, кто знает (уже пробовал эти примеры), чего ему не хватает?

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
Private Sub cmdNoTryCatch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdNoTryCatch.Click
		''--Ask to make sure the user is willing to possibly blow up the program.
		Dim strMsg As String = "The following code has no error handling and will cause an unhandled exception if a file is not found. Do you want to continue?"
        If MessageBox.Show(strMsg, Me.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) = DialogResult.Yes Then
            ''-- Use the FileStream class from the System.IO Namespace (see Imports at top of file).
            Dim fs As FileStream

            ''-- This command will fail if the file does not exist.
            fs = File.Open(Me.txtFileName.Text, FileMode.Open)
            MessageBox.Show("The size of the file is: " & fs.Length, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Information)
            fs.Close()

        End If
	End Sub
...
Рейтинг: 0 / 0
12.09.2006, 17:41
    #33981893
mishazhutov
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
VB.NET How-To Try, Catch, Finally
Если не нравится DialogResult.Yes, замените его на System.Windows.Forms.DialogResult.Yes, хотя я взял, вставил этот код в WindowsForms приложение и у меня все работает.
...
Рейтинг: 0 / 0
13.09.2006, 10:57
    #33983202
BrokenPot
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
VB.NET How-To Try, Catch, Finally
А мне пришлось-таки добавить. Спасибо.
...
Рейтинг: 0 / 0
Форумы / ASP.NET [игнор отключен] [закрыт для гостей] / VB.NET How-To Try, Catch, Finally / 3 сообщений из 3, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]