elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.


Tema destacado: Arreglado, de nuevo, el registro del warzone (wargame) de EHN


  Mostrar Mensajes
Páginas: 1 ... 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 [1036] 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 ... 1254
10351  Programación / .NET (C#, VB.NET, ASP) / Re: Cuando compilo mi aplicación, no funciona. en: 21 Noviembre 2012, 17:50 pm
Cuando abres la app por 1ª vez, ¿cómo está inicializado My.Settings.Valores ?
No se si te refieres a esto, es Int32, con valor "0"

Podrías crearte un Sub con el código que metes en el FormClosing y ese Sub meterlo en Load llámandolo antes del CargaPropiedades, si My.Settings.Valores no está inicializado.
¿Y como compruebo si está inicializada?
Yo he intentado un:
Código
  1. MsgBox(My.Settings.Valores.ToString())
para ver si es "0", pero no se ejecuta el msgbox (ni el resto de código que sigue debajo).
10352  Programación / .NET (C#, VB.NET, ASP) / Re: La carpeta bin se me llena de dll's que mi app no utiliza en: 21 Noviembre 2012, 17:33 pm
¿Solo son controles que fuiste agregando?
si

Intenta dando botón derecho sobre la solución, hay una opción de "clean solution" (limpiar solución), y luego vuelve a compilar

Ya lo hice Nov, me borra las dll de la carpeta (en realidad me borra todo lo que haya en la carpeta...), y cuando vuelvo a compilar desde la IDE vuelve a agregar todas esas dll a la carpeta, y no me deja ejecutar el .exe sin esas dll  :xD

Quizás es una tontería pero por si tiene algo que ver, estoy en modo "debug", no "release".

saludos
10353  Programación / .NET (C#, VB.NET, ASP) / Re: ¿Como hacer el .exe para todos los ordenadores? (Visual Basics 2012)? en: 21 Noviembre 2012, 17:30 pm
Aun no me deja, por lo menos me sale que dejo de responder pero sige sin ir.  :-(

No es que no tengan el visual basic, es que no tienen el .net framework..

@enriquefemo
Si no entendiste esa parte dilo, debes instalar en tu PC (y en los otros) la versión adecuada de Framework...
De todas formas si cambias en las propiedades el framework a 2.0 dudo que te siga sin funcionar en winxp/vista/7/8 ...

http://www.microsoft.com/es-es/download/details.aspx?id=30653
10354  Programación / .NET (C#, VB.NET, ASP) / Re: ¿Como hacer el .exe para todos los ordenadores? (Visual Basics 2012)? en: 21 Noviembre 2012, 17:08 pm
No soy ningún experto pero en las propiedades del programa puedes requerir una versión inferior del framework:



Saludos
10355  Programación / .NET (C#, VB.NET, ASP) / (solucionado) La carpeta bin se me llena de dll's que mi app no utiliza en: 21 Noviembre 2012, 17:02 pm


Todas esas dlls controles en realidad mi app no las utiliza, las añadí a mi form para ver lo que hacian y si me podian servir para algún propósito, pero después de eso las eliminé (usando el botón eliminar)

¿Donde debo borrar los rastros que quedan de esas dll's?

¿Hay alguna extensión para VS2012 que haga esto automáticamente por mi?

Saludos
10356  Programación / .NET (C#, VB.NET, ASP) / Re: Cuando compilo mi aplicación, no funciona. en: 21 Noviembre 2012, 16:59 pm
Coloca el código que esta en Form_Load, nunca digas que no puedes hacer algo, aquí todos comenzamos con Hola Mundo, y como tu puedes ver ya has avanzado ¿o no? ;) No te rindas tan fácilmente se necesita mucha perseverancia para terminar un proyecto precisamente por la paciencia que hay que tener para hallar y solucionar los errores.

Gracias.

Pues mejor pongo todo el form (Aún le estoy retocando lo del Drag&Drop):

Código
  1. Imports System.Windows.Forms
  2. Imports System.IO
  3.  
  4. Public Class Form1
  5.    Dim filesystem As Object, ThisDir As Object
  6.    Dim mcheck(0) As CheckBox
  7.    Dim playerargs As String
  8.  
  9.  
  10. #Region "Propertys"
  11.  
  12.    'userSelectedPlayerFilePath
  13.    Public Property userSelectedPlayerFilePath() As String
  14.        Get
  15.            Return playertextbox.Text
  16.        End Get
  17.        Set(value As String)
  18.            playertextbox.Text = value
  19.        End Set
  20.    End Property
  21.  
  22.    ' userSelectedFolderPath
  23.    Public Property userSelectedFolderPath() As String
  24.        Get
  25.            Return foldertextbox.Text
  26.        End Get
  27.        Set(value As String)
  28.            foldertextbox.Text = value
  29.        End Set
  30.    End Property
  31.  
  32. #End Region
  33.  
  34. #Region "Load / Close"
  35.  
  36.    ' Form load
  37.    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
  38.        Try
  39.  
  40.            Me.Text = My.Settings.APPName & " - By Elektro H@cker"
  41.  
  42.            If Not My.Computer.FileSystem.DirectoryExists(My.Settings.folderpath) Then
  43.                foldertextbox.Text = "Selext a folder..."
  44.                Me.Size = New System.Drawing.Size(362, 228)
  45.                Panel1.Size = New System.Drawing.Size(0, 0)
  46.                My.Settings.folderpath = Nothing
  47.                My.Settings.Save()
  48.            Else
  49.                foldertextbox.Text = My.Settings.folderpath
  50.            End If
  51.  
  52.            If Not My.Computer.FileSystem.FileExists(My.Settings.playerpath) Then
  53.                playertextbox.Text = "Selext a music player..."
  54.                My.Settings.playerpath = Nothing
  55.                My.Settings.Save()
  56.            Else
  57.                playertextbox.Text = My.Settings.playerpath
  58.            End If
  59.  
  60.            updatecheckboxes()
  61.            CargarPropiedades()
  62.        Catch
  63.  
  64.        End Try
  65.  
  66.    End Sub
  67.  
  68.    ' Form close
  69.    Private Sub Form1_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
  70.        Dim mCheckados(0) As Int32
  71.        Dim Cuantos As Int32 = 0
  72.        Dim empty = Nothing
  73.  
  74.        For Each c As CheckBox In Panel1.Controls
  75.            empty = "no"
  76.        Next
  77.        If Not empty = "no" Then
  78.            My.Settings.Valores = Nothing
  79.        Else
  80.            For i As Int32 = 0 To mcheck.Length - 1
  81.                If mcheck(i).Checked = True Then
  82.                    Cuantos += 1
  83.                    Array.Resize(mCheckados, Cuantos)
  84.                    mCheckados(Cuantos - 1) = i + 1
  85.                End If
  86.            Next
  87.            My.Settings.Valores = mCheckados
  88.        End If
  89.  
  90.        My.Settings.Save()
  91.    End Sub
  92.  
  93. #End Region
  94.  
  95.  
  96. #Region "Save / Get settings"
  97.  
  98.    ' Generate propertys
  99.    Public Sub GenerarPropiedades()
  100.        Dim CheckedN As String = Nothing
  101.        For i As Int32 = 0 To mcheck.Length - 1
  102.            If mcheck(i).Checked = True Then
  103.                CheckedN &= i + 1
  104.            End If
  105.        Next
  106.        My.Settings.Save()
  107.    End Sub
  108.  
  109.    ' load propertys
  110.    Private Sub CargarPropiedades()
  111.        Dim ListaCheckados As Int32() = My.Settings.Valores
  112.        For i As Int32 = 0 To mcheck.Length - 1
  113.            For Each indiceCheckado As Int32 In ListaCheckados
  114.                mcheck(indiceCheckado - 1).Checked = True
  115.            Next
  116.        Next
  117.    End Sub
  118.  
  119. #End Region
  120.  
  121.  
  122. #Region "Checkboxes"
  123.  
  124.    ' Checkbox drawing
  125.    Public Sub updatecheckboxes()
  126.        ' delete the old checkboxes
  127.        Panel1.Controls.Clear()
  128.        ' create the new checkboxes
  129.        Dim filesystem = CreateObject("Scripting.FileSystemObject")
  130.        Dim ThisDir = filesystem.GetFolder(My.Settings.folderpath)
  131.        Dim i As Int32 = 0
  132.        Dim pos As Int32 = 10
  133.        For Each folder In ThisDir.Subfolders
  134.            Array.Resize(mcheck, i + 1)
  135.            mcheck(i) = New CheckBox
  136.            With mcheck(i)
  137.                .AutoSize = True
  138.                .Location = New Point(10, pos)
  139.                .Name = "CheckBox" & i + 1
  140.                .Text = folder.Name
  141.            End With
  142.            Me.Panel1.Controls.Add(mcheck(i))
  143.            AddHandler mcheck(i).CheckedChanged, AddressOf LlamadaCheckBox
  144.            i += 1
  145.            pos += 20
  146.        Next
  147.  
  148.    End Sub
  149.  
  150.    ' Checkbox events
  151.    Public Sub LlamadaCheckBox(ByVal sender As Object, ByVal e As System.EventArgs)
  152.        Dim filesystem = CreateObject("Scripting.FileSystemObject")
  153.        Dim ThisDir = filesystem.GetFolder(My.Settings.folderpath)
  154.        Dim CheckboxN As CheckBox = CType(sender, CheckBox)
  155.        If CheckboxN.Checked = True Then
  156.            playerargs = playerargs & " " & ControlChars.Quote & Path.Combine(ThisDir.Path, CheckboxN.Text.ToString()) & ControlChars.Quote
  157.        Else
  158.            playerargs = Replace(playerargs, " " & ControlChars.Quote & Path.Combine(ThisDir.Path, CheckboxN.Text.ToString()) & ControlChars.Quote, "")
  159.        End If
  160.    End Sub
  161.  
  162. #End Region
  163.  
  164.  
  165. #Region "Buttons"
  166.  
  167.    ' Folder button
  168.    Public Sub C1Button3_Click(sender As Object, e As EventArgs) Handles folderbutton.Click
  169.        Dim folderselected As New System.Windows.Forms.FolderBrowserDialog
  170.        Dim Resultado As DialogResult
  171.        folderselected.RootFolder = Environment.SpecialFolder.Desktop
  172.        Resultado = folderselected.ShowDialog
  173.        If Resultado.ToString() = "OK" Then
  174.            userSelectedFolderPath = folderselected.SelectedPath
  175.            My.Settings.folderpath = folderselected.SelectedPath
  176.            My.Settings.Save()
  177.            playerargs = Nothing
  178.            Me.Size = New System.Drawing.Size(362, 540)
  179.            Panel1.Size = New System.Drawing.Size(322, 296)
  180.            updatecheckboxes()
  181.        End If
  182.    End Sub
  183.  
  184.    ' Player button
  185.    Public Sub C1Button1_Click(sender As Object, e As EventArgs) Handles playerbutton.Click
  186.        Dim playerselected As New OpenFileDialog()
  187.        playerselected.InitialDirectory = Environ("programfiles")
  188.        playerselected.Title = "Select your favorite music player"
  189.        playerselected.Filter = "Music players|bsplayer.exe;mpc.exe;mpc-hc.exe;mpc-hc64.exe;umplayer.exe;vlc.exe;winamp.exe;wmp.exe"
  190.        PlayerDialog.FilterIndex = 1
  191.        Dim selection As System.Windows.Forms.DialogResult = playerselected.ShowDialog()
  192.        If selection = DialogResult.OK Then
  193.            userSelectedPlayerFilePath = playerselected.FileName
  194.            My.Settings.playerpath = playerselected.FileName
  195.            My.Settings.Save()
  196.        End If
  197.    End Sub
  198.  
  199.    ' Play button
  200.    Public Sub C1Button2_Click(sender As Object, e As EventArgs) Handles playbutton.Click
  201.        If Not playerargs = Nothing Then
  202.            Process.Start(userSelectedPlayerFilePath, playerargs)
  203.            If autoclose.Checked = True Then
  204.                Me.Close()
  205.            End If
  206.        Else
  207.            MessageBox.Show("You must select at least one folder...", My.Settings.APPName)
  208.        End If
  209.    End Sub
  210.  
  211.    ' Select  ALL checkboxes
  212.    Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles selectall.CheckedChanged
  213.        If selectall.Checked = False Then
  214.            For Each ctrl In Panel1.Controls
  215.                ctrl.Checked = False
  216.            Next
  217.            selectall.Text = "Select all"
  218.        Else
  219.            For Each ctrl In Panel1.Controls
  220.                ctrl.Checked = True
  221.            Next
  222.            selectall.Text = "Unselect all"
  223.        End If
  224.    End Sub
  225.  
  226. #End Region
  227.  
  228.  
  229. #Region "Drag & Drop"
  230.  
  231.  
  232.  
  233.  
  234.    Private Sub Panel1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Panel1.DragDrop
  235.        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
  236.            Dim Objetos As String() = e.Data.GetData(DataFormats.FileDrop)
  237.            Panel1.Text = Objetos(0)
  238.            userSelectedFolderPath = Objetos(0)
  239.            My.Settings.folderpath = Objetos(0)
  240.            My.Settings.Save()
  241.            playerargs = Nothing
  242.            updatecheckboxes()
  243.        End If
  244.    End Sub
  245.  
  246.    Private Sub Panel1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Panel1.DragEnter
  247.        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
  248.            e.Effect = DragDropEffects.All
  249.        End If
  250.    End Sub
  251.  
  252.   Private Sub TextBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles foldertextbox.DragDrop
  253.        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
  254.            Dim Objetos As String() = e.Data.GetData(DataFormats.FileDrop)
  255.  
  256.            Dim attributes = Objetos(0)
  257.            If ((attributes And FileAttributes.Directory) = FileAttributes.Directory) Then
  258.                MsgBox("es un dir")
  259.            Else
  260.                MsgBox("no es un dir")
  261.            End If
  262.  
  263.            foldertextbox.Text = Objetos(0)
  264.            userSelectedFolderPath = Objetos(0)
  265.            My.Settings.folderpath = Objetos(0)
  266.            My.Settings.Save()
  267.            playerargs = Nothing
  268.            updatecheckboxes()
  269.        End If
  270.    End Sub
  271.  
  272.    Private Sub TextBox1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles foldertextbox.DragEnter
  273.        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
  274.            e.Effect = DragDropEffects.All
  275.        End If
  276.    End Sub
  277.  
  278. #End Region
  279.  
  280.  
  281. End Class
10357  Programación / .NET (C#, VB.NET, ASP) / Re: Cuando compilo mi aplicación, no funciona. en: 21 Noviembre 2012, 16:51 pm
Es mala practica no controlar los errores, debes manejar todas las excepciones, validar absolutamente todo.

Tienes toda la razón, es mala práctica, pero pienso que para solventar ese tipo de cosas hay que tener mejor dominio del lenguaje, del que tengo yo.

Un saludo!
10358  Programación / .NET (C#, VB.NET, ASP) / Re: Cuando compilo mi aplicación, no funciona. en: 21 Noviembre 2012, 16:35 pm
Esa ventana es aviso de una excepción no controlada, si lees da mucha información acerca de donde y como se dio el error, tienes que revisar el código en el lugar donde te dice que lo hubo, buscando valores inválidos, variables no inicializadas, divisiones por 0, desbordamientos y ese tipo de cosas.

Gracias, pero entonces no se puede desactivar ese tipo de avisos desde el "app.config" o en algún sitio?


EDITO: Te agradezco mucho los datos que me has dado pero no me apetece nada buscar " divisiones por 0, desbordamientos" porque nos e hacerlo, y la app funciona perfectamente aunque el debugger me diga que no.

Lo he arreglado de una manera más fácil, añadiendo una excepción en el form load.  :xD

Un saludo
10359  Programación / .NET (C#, VB.NET, ASP) / Cuando compilo mi aplicación, no funciona. en: 21 Noviembre 2012, 16:27 pm
Cuando compilo la app y la ejecuto me sale esto:



Pero cuando ejecuto la app desde el IDE no me sale ningún error (Bueno, menos en la consola, me sale una excepción en rojo) pero el programa funciona perfectamente apesar de esa excepción...

¿Hay alguna manera de evitar que salga esa ventana sin tener que investigar dentro del código del form?
10360  Programación / .NET (C#, VB.NET, ASP) / Re: AllowDrop... como narices usarlo? en: 21 Noviembre 2012, 16:14 pm
No he podido hacer la comparación entre directorio y archivo, ¿Que estoy haciendo mal?


Código
  1.    Private Sub TextBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles foldertextbox.DragDrop
  2.        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
  3.            Dim Objetos As String() = e.Data.GetData(DataFormats.FileDrop)
  4.  
  5.            Dim attributes = Objetos(0)
  6.            If ((attributes And FileAttributes.Directory) = FileAttributes.Directory) Then
  7.                MsgBox("es un dir")
  8.            Else
  9.                MsgBox("no es un dir")
  10.            End If

Citar
Conversion from string "C:\Users\Administrador\Desktop\W" to type 'Long' is not valid.
Páginas: 1 ... 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 [1036] 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 ... 1254
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines