Usuário com melhor resposta
Select Case dúvida

Pergunta
-
Estou a tentar criar uma espécie de slideshow. Meu objetivo era ter uma picturebox de X em X tempo a imagem mudava. Tipo uma animação usando uma imagem tipo loading
Para isso estava a pensar em usar o Case mas o que devo meter a seguir ao
Select Case
Select Case 'o que vai aqui Case 0 PictureBox1.Backgroundimage = My.Resources.Load1 Case 1 PictureBox1.Backgroundimage = My.Resources.Load2 Case 2 PictureBox1.Backgroundimage = My.Resources.Load3 Case 3 PictureBox1.Backgroundimage = My.Resources.Load4
E já agora estou a proseguir bem no resto do código ??
Meu novo programa (Bloco de Notas) http://hyrokumata-app.blogspot.pt/2012/07/notepad-3-beta.html
Respostas
-
Problema resolvido. Em vez de usar o bixo Select Case adicionei 6 timer para as 6 imagens
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick PictureBox1.BackgroundImage = My.Resources.load1 Timer1.Enabled = False Timer2.Enabled = True End Sub Private Sub Dialog1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Timer1.Enabled = True End Sub Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick PictureBox1.BackgroundImage = My.Resources.load4 Timer4.Enabled = False Timer5.Enabled = True End Sub Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick PictureBox1.BackgroundImage = My.Resources.load3 Timer3.Enabled = False Timer4.Enabled = True End Sub Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick PictureBox1.BackgroundImage = My.Resources.load2 Timer2.Enabled = False Timer3.Enabled = True End Sub Private Sub Timer6_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer6.Tick PictureBox1.BackgroundImage = My.Resources.load6 Timer6.Enabled = False Timer1.Enabled = True End Sub Private Sub Timer5_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer5.Tick PictureBox1.BackgroundImage = My.Resources.load5 Timer5.Enabled = False Timer6.Enabled = True
Meu novo programa (Bloco de Notas) http://hyrokumata-app.blogspot.pt/2012/07/notepad-3-beta.html
- Marcado como Resposta Harley AraujoModerator terça-feira, 28 de agosto de 2012 12:45
Todas as Respostas
-
-
-
sintaxe do case
WL_DSSQL += " Case t1.status_cartao " WL_DSSQL += " When 0 Then 'Ativo'" WL_DSSQL += " When 1 Then 'Bloqueado'" WL_DSSQL += " When 2 Then 'Bloqueado'" WL_DSSQL += " When 3 then 'Bloqueado'" WL_DSSQL += " When 4 then 'Bloqueado'" WL_DSSQL += " When 5 then 'Bloqueado'" WL_DSSQL += " When 6 then 'Sem Cartão'" WL_DSSQL += " When 7 then 'Inat.Desuso'" WL_DSSQL += " End as status ," wl_dssql += from cliente t1
Junior
-
Olá Fábio
O que você vai colocar no "Select Case ...." depende do que você quer, veja um exemplo:
Obs.: No exemplo abaixo tenho a variável "quantidade" que irá receber algum valor e dependendo do valor irá executar um código específico.
Select Case quantidade Case 1 'caso valor de quantidade seja 1, executa rotina1 rotina1() Case 2 'caso valor seja 2, executa rotina2 rotina2() Case 3 to 6 'caso o valor esteja entre 3 e 6, executa a rotina3 rotina3() Case else rotina4() End Select
Att.,
Jeimes Ribeiro
-
Olá, será a sua variável de controle, veja:
Dim controle As Int controle = 2 Select Case controle Case 0 PictureBox1.Backgroundimage = My.Resources.Load1 Case 1 PictureBox1.Backgroundimage = My.Resources.Load2 Case 2 PictureBox1.Backgroundimage = My.Resources.Load3 Case 3 PictureBox1.Backgroundimage = My.Resources.Load4
Neste caso, entrará no "Case 2" pois a variável "controle" possui o valor 2.
Espero ter ajudado, abraços!
Thiago Coelho - Líder da Comunidade .NET Coders
thiagocoelho.net | @thiagokoelho | Windows 8 Brasil -
Olá, será a sua variável de controle, veja:
Dim controle As Int controle = 2 Select Case controle Case 0 PictureBox1.Backgroundimage = My.Resources.Load1 Case 1 PictureBox1.Backgroundimage = My.Resources.Load2 Case 2 PictureBox1.Backgroundimage = My.Resources.Load3 Case 3 PictureBox1.Backgroundimage = My.Resources.Load4
Neste caso, entrará no "Case 2" pois a variável "controle" possui o valor 2.
Espero ter ajudado, abraços!
Thiago Coelho - Líder da Comunidade .NET Coders
thiagocoelho.net | @thiagokoelho | Windows 8 BrasilO problema é esse. Eu queria fazer tipo um slidehow usando apenas uma picturebox
Pensei em usar o Case porque posso usar como generador
Eu queria que ele fizesse todos os Case
O primeiro código que fiz foi:
Dim teste As Integer = 0 Select Case teste Case 0 PictureBox1.BackgroundImage = My.Resources.load1 Case 1 PictureBox1.BackgroundImage = My.Resources.load2 Case 2 PictureBox1.BackgroundImage = My.Resources.load3 Case 3 PictureBox1.BackgroundImage = My.Resources.load4 End Select 'apenas mosstra o Case 0
Mas como disse e muito bem só vai mostrar um case
Meu novo programa (Bloco de Notas) http://hyrokumata-app.blogspot.pt/2012/07/notepad-3-beta.html
-
-
-
Problema resolvido. Em vez de usar o bixo Select Case adicionei 6 timer para as 6 imagens
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick PictureBox1.BackgroundImage = My.Resources.load1 Timer1.Enabled = False Timer2.Enabled = True End Sub Private Sub Dialog1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Timer1.Enabled = True End Sub Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick PictureBox1.BackgroundImage = My.Resources.load4 Timer4.Enabled = False Timer5.Enabled = True End Sub Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick PictureBox1.BackgroundImage = My.Resources.load3 Timer3.Enabled = False Timer4.Enabled = True End Sub Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick PictureBox1.BackgroundImage = My.Resources.load2 Timer2.Enabled = False Timer3.Enabled = True End Sub Private Sub Timer6_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer6.Tick PictureBox1.BackgroundImage = My.Resources.load6 Timer6.Enabled = False Timer1.Enabled = True End Sub Private Sub Timer5_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer5.Tick PictureBox1.BackgroundImage = My.Resources.load5 Timer5.Enabled = False Timer6.Enabled = True
Meu novo programa (Bloco de Notas) http://hyrokumata-app.blogspot.pt/2012/07/notepad-3-beta.html
- Marcado como Resposta Harley AraujoModerator terça-feira, 28 de agosto de 2012 12:45