Ir ao conteúdo
  • Cadastre-se

Visual Basic Express Edition 2005


Josias123

Posts recomendados

Estou aprendendo visual basic a fiz o download do Express edition. Estou fazendo este simples programa e não consigo descobrir como consertar esse codigo(em negrito e o que esta errado):

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

PictureBox1.Visible = False

Label1 = Int(Rnd() * 10)

Label2 = Int(Rnd() * 10)

Label3 = Int(Rnd() * 10)

If (Label1 = 7) Or (Label2 = 7) Or (Label3 = 7) Then

PictureBox1.Visible = True

Beep()

End If

End Sub

Os comentarios do program sao os seguintes:

(para os tres primeitos)

Error 1 Value of type 'Single' cannot be converted to 'System.Windows.Forms.Label'.

e para os tres ultimos erros)

Error 6 Operator '=' is not defined for types 'System.Windows.Forms.Label' and 'Integer'.

Li em um artigo que no express edition não preciso colocar Caption porque Label tem automaticamente esta prpriedade.

Alguem pode me dar uma luz.

Link para o comentário
Compartilhar em outros sites

Pelo que percebi você que atribuir um valor a propriedade Caption da Label, faça o seguinte:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

PictureBox1.Visible = False

Label1.Caption = Int(Rnd() * 10).ToString()

Label2.Caption = Int(Rnd() * 10).ToString()

Label3.Caption = Int(Rnd() * 10).ToString()

If (Label1.Caption = "7") Or (Label2.Caption = "7") Or (Label3.Caption = "7") Then

PictureBox1.Visible = True

Beep()

End If

End Sub

Link para o comentário
Compartilhar em outros sites

Valeu pela resposta. EU tentei agora o codigo aparece assim(em negrito estão as partes que o VB considera erradas):

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

PictureBox1.Visible = False

Label1.Caption = Int(Rnd() * 10).ToString()

Label2.Caption = Int(Rnd() * 10).ToString()

Label3.Caption = Int(Rnd() * 10).ToString()

If (Label1.Caption = "7") Or (Label2.Caption = "7") Or (Label3.Caption = "7") Then

PictureBox1.Visible = True

Beep()

End If

E os comentarios sao:

Error 1 'Caption' is not a member of 'System.Windows.Forms.Label'. C:\Documents and Settings\Diego\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.vb 5 9 WindowsApplication1

Error 2 'Caption' is not a member of 'System.Windows.Forms.Label'. C:\Documents and Settings\Diego\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.vb 6 9 WindowsApplication1

Error 3 'Caption' is not a member of 'System.Windows.Forms.Label'. C:\Documents and Settings\Diego\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.vb 7 9 WindowsApplication1

Error 4 'Caption' is not a member of 'System.Windows.Forms.Label'. C:\Documents and Settings\Diego\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.vb 8 13 WindowsApplication1

Error 5 'Caption' is not a member of 'System.Windows.Forms.Label'. C:\Documents and Settings\Diego\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.vb 8 39 WindowsApplication1

Error 6 'Caption' is not a member of 'System.Windows.Forms.Label'. C:\Documents and Settings\Diego\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.vb 8 65 WindowsApplication1

ALguma luz?????

Link para o comentário
Compartilhar em outros sites

  • Membro VIP

Josias...

A primeira coisa,

VB6 e VB.Net são duas coisas diferentes, tem nome parecido e sintaxe parecida, mas as semelhanças acabam ai,

As apostilas que você baixa na internet para VB6 funciam perfeitamente, no VB6, no VB.Net não,

Esse codigo ai substituindo caption por text deve funcionar (se bem que não boto minha mão no fogo pelo Beep() que tem ai), mas não é regra, melhor procurar um tutorial de VB.Net mesmo.

Link para o comentário
Compartilhar em outros sites

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

 

GRÁTIS: ebook Redes Wi-Fi – 2ª Edição

EBOOK GRÁTIS!

CLIQUE AQUI E BAIXE AGORA MESMO!