Inquiridor
CheckBox

Pergunta
-
o que tem de erado neste codigo galera pois não esta a dar certo perfeitamente obrigado a todos
Imports System.IO
Public Class OPçao
Dim aa As String
Dim a As String
Dim b As String
Dim c As String
Private Sub OPçao_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Visible = False
Me.Hide()
Me.Opacity = 0.88 '88%
Try
Dim aa As String() = Split(File.ReadAllText(Application.StartupPath & "\Settings.ini"))
Dim a As String() = Split(File.ReadAllText(Application.StartupPath & "\Settings2.ini"))
Dim b As String() = Split(File.ReadAllText(Application.StartupPath & "\Settings3.ini"))
Dim c As String() = Split(File.ReadAllText(Application.StartupPath & "\Settings4.ini"))
If aa(0) = "true" Then CheckBox1.Checked = True Else CheckBox1.Checked = False
If a(0) = "true" Then CheckBox2.Checked = True Else CheckBox2.Checked = False
If b(0) = "true" Then CheckBox3.Checked = True Else CheckBox3.Checked = False
If c(0) = "true" Then CheckBox4.Checked = True Else CheckBox4.Checked = False
Catch : End Try
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
If File.Exists(Application.StartupPath & "\Settings.ini") Then File.Delete(Application.StartupPath & "\Settings.ini")
If File.Exists(Application.StartupPath & "\Settings2.ini") Then File.Delete(Application.StartupPath & "\Settings2.ini")
If File.Exists(Application.StartupPath & "\Settings3.ini") Then File.Delete(Application.StartupPath & "\Settings3.ini")
If File.Exists(Application.StartupPath & "\Settings4.ini") Then File.Delete(Application.StartupPath & "\Settings4.ini")
If CheckBox1.Checked = True Then aa += "true|" Else aa += "false|"
If CheckBox2.Checked = True Then a += "true|" Else a += "false|"
If CheckBox3.Checked = True Then b += "true|" Else b += "false|"
If CheckBox4.Checked = True Then c += "true|" Else c += "false|"
File.WriteAllText(Application.StartupPath & "\Settings.ini", aa)
File.WriteAllText(Application.StartupPath & "\Settings2.ini", aa)
File.WriteAllText(Application.StartupPath & "\Settings3.ini", aa)
File.WriteAllText(Application.StartupPath & "\Settings4.ini", aa)
Catch : End Try
Button1.Text = ("True")
End Sub
Private Sub CheckBox2_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox2.CheckedChanged
If CheckBox2.Checked = True Then
Form1.Logs1.Show()
Else
Form1.Logs1.Hide()
End If
End Subend class
Todas as Respostas
-
Bom dia,
Mas qual gero ele erra?
Debuga ele e posta a parte que gera esse erro, que assim fica mais fácil pro pessoal te ajudar.
Fico no aguardo,
Att,
Ricardo Cortes Microsoft Contingent Staff
Esse contedo e fornecido sem garantias de qualquer tipo, seja expressa ou implicita.
MSDN Community Support
-
-
Boa noite @joao pjoao1578,
O colega @Ricardo pediu para que você nos passe qual é a linha que está gerando o erro e qual erro está sendo gerado.
Assim facilita aos colegas da comunidade a ajudarem você a resolver o problema.
Caso não tenha conhecimento de como debugar a sua aplicação, abaixo seguem alguns links que podem te ajudar:
http://msdn.microsoft.com/en-us/library/ms172744.aspx
http://msdn.microsoft.com/en-us/library/kz97zky6(v=vs.90).aspx
https://www.youtube.com/watch?v=Uk-a7qVa36c
Espero ter ajudado,
TP.
Thiago Patrocinio
- Editado Thiago Patrocinio terça-feira, 18 de novembro de 2014 23:41
-
-
Boa tarde @joao pjoao1578,
Acredito que seja válido você postar a solução do problema e marcar como resposta, assim fechamos a thread e ajudamos a contribuir com alguém que venha a ter o mesmo problema no futuro :)
Até mais,
TP.Thiago Patrocinio
-
aqui esta a solução
'Feito por pjoao1578'
Imports System.IO
Public Class OPçao
Dim aa As String
Dim a As String
Dim b As String
Dim c As String
Private Sub OPçao_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Visible = False
Me.Hide()
Me.Opacity = 0.88 '88%
If IO.File.Exists("config.txt") Then
CheckBox2.Checked = IO.File.ReadAllText("config.txt")
End If
If IO.File.Exists("config1.txt") Then
CheckBox1.Checked = IO.File.ReadAllText("config1.txt")
End If
If IO.File.Exists("config2.txt") Then
CheckBox3.Checked = IO.File.ReadAllText("config2.txt")
End If
If IO.File.Exists("config3.txt") Then
CheckBox4.Checked = IO.File.ReadAllText("config3.txt")
End If
Button1.Text = ("Salva")
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Using ficheiro As New IO.StreamWriter("config.txt")
ficheiro.Write(CheckBox2.Checked = True)
End Using
Using ficheiro As New IO.StreamWriter("config1.txt")
ficheiro.Write(CheckBox1.Checked = True)
End Using
Using ficheiro As New IO.StreamWriter("config2.txt")
ficheiro.Write(CheckBox3.Checked = True)
End Using
Using ficheiro As New IO.StreamWriter("config3.txt")
ficheiro.Write(CheckBox4.Checked = True)
End Using
Button1.Text = ("True")
End Sub
Private Sub CheckBox2_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox2.CheckedChanged
If CheckBox2.Checked = True Then
Form1.Logs1.Show()
Button1.Text = ("Salvar?")
Else
Form1.Logs1.Hide()
Button1.Text = ("Salvar?")
End If
End Sub
Private Sub CheckBox4_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox4.CheckedChanged, CheckBox4.CheckedChanged
If CheckBox4.Checked = True Then
Form1.Opacity = 0.88
Else
Form1.Opacity = 100
End If
Button1.Text = ("Salvar?")
End Sub
Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = True Then
Form1.P1.Show()
Button1.Text = ("Salvar?")
Else
Form1.P1.Hide()
Button1.Text = ("Salvar?")
End If
End Sub
Private Sub CheckBox3_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox3.CheckedChanged
If CheckBox3.Checked = True Then
Form1.L2.Show()
Button1.Text = ("Salvar?")
Else
Form1.L2.Hide()
Button1.Text = ("Salvar?")
End If
End Sub
Private Sub ExitOpçõesToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExitOpçõesToolStripMenuItem.Click
Form1.NJ.Visible = False
Me.Visible = False
End Subend class
- Sugerido como Resposta Thiago Patrocinio quinta-feira, 20 de novembro de 2014 16:18