Cesar_PT Posted November 29, 2020 at 06:35 PM Report Share #620485 Posted November 29, 2020 at 06:35 PM Boa noite. Ao clicar no Start no Visual Studio abre normalmente o programa. Ao abrir o programa (.exe) pelo bin/Debug ele apresenta um erro: O incremento não deverá ser chamado se o estilo for Painel Rolante. Antes eu coloquei um ProgressBar com um Timer, ao chegar a 100% abre o Form Inicio e fecha o atual. Timer: Private Sub TimerCountDown_Tick(sender As Object, e As EventArgs) Handles TimerCountDown.Tick 'Incrementar 1 no intervalo de tempo 150 milésimos de segundo ProgressBarSplashScreen.Increment(1) If ProgressBarSplashScreen.Value = ProgressBarSplashScreen.Maximum Then TimerCountDown.Stop() Inicio.Show() Me.Close() End If If ProgressBarSplashScreen.Value > 1 And ProgressBarSplashScreen.Value < 100 Then LabelSplashScreen.Text = String.Format("A carregar {0}%", {ProgressBarSplashScreen.Value}) ElseIf ProgressBarSplashScreen.Value = 100 Then LabelSplashScreen.Text = "A carregar {100%}" End If End Sub Erro: https://i.postimg.cc/YqPrVxCZ/5RiQb3p.png Alguém me poderia ajudar por favor? Link to comment Share on other sites More sharing options...
Cesar_PT Posted November 29, 2020 at 08:44 PM Author Report Share #620491 Posted November 29, 2020 at 08:44 PM Resolvido. Estava a dar conflito entre os Ifs. Link to comment Share on other sites More sharing options...
Solution ribeiro55 Posted November 30, 2020 at 10:41 AM Solution Report Share #620497 Posted November 30, 2020 at 10:41 AM O erro refere-se ao não fazer sentido chamar o Increment, quando o estilo que definiste para a progress bar é Marquee, porque Marquee é um estilo constante. A única forma de resolver isso é trocar o estilo de Marquee para Blocks, ou Continuous. Provavelmente foi o que fizeste sem te aperceberes pois nenhuma alteração ao teu código faria a a excepção não ser levantada. Em tom de sugestão, (não estou a testar) o teu código poderia traduzir-se por uma forma mais reduzida, como esta: Private Sub TimerCountDown_Tick(sender As Object, e As EventArgs) Handles TimerCountDown.Tick If ProgressBarSplashScreen.Value = ProgressBarSplashScreen.Maximum Then TimerCountDown.Stop() Inicio.Show() Me.Close() End If ProgressBarSplashScreen.Increment(1) LabelSplashScreen.Text = String.Format("A carregar {0}%", {ProgressBarSplashScreen.Value}) End Sub Agora, numa questão mais filosófica, fará sentido usares uma progress bar temporizada? Não estás a carregar absolutamente nada. Do ponto de vista do utilizador, eu quero ver o teu splash screen o menor tempo possível, nenhum até, de preferência. Se o estás a atrasar por motivos de branding, prefiro não ver a progressbar, a ter que rezar de todas as vezes para que o "carregamento" seja mais rápido: nunca vai ser. Sérgio Ribeiro "Great coders aren't born. They're compiled and released""Expert coders do not need a keyboard. They just throw magnets at the RAM chips" Link to comment Share on other sites More sharing options...
Cesar_PT Posted November 30, 2020 at 11:10 AM Author Report Share #620498 Posted November 30, 2020 at 11:10 AM Boa tarde @ribeiro55. Sim, eu tinha antes testado com marquee mas depois mudei para blocks, salvei tudo, mas acho que no bin/Debug ainda tinha a versão desatualizada. Quanto à questão do carregamento, sim eu coloquei um progress bar por 10 segundos, para o utilizador ver o que o programa faz. Mas em cima dele tem um botão para saltar para ir direto para o Form. E obrigado pela ajuda 😃 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now