|
131
|
Programación / .NET (C#, VB.NET, ASP) / Aburrido harto de la publicidad a ver si se puede hacer esto
|
en: 29 Octubre 2015, 17:35 pm
|
Hola de nuevo , hoy no vengo con numeros jejejje me estoy haciendo un programita para ir blokeando las paginas basura que me saltan de ves en cuando y pense que seria facil cojer un testbox una variable y ya , la idea es blokear (ahora lo hago a mano ) las direcciones de estas molestas paginas en el archivo Host .pero me encontre con otros problemas y despues de mirar y remirar no veo como hacerlo. Problema 1: escribir en el archivo sin sobreescribir lo ya puesto y que continue en el ultimo registro problema 2: hay que poner 127.0.0.1 y un margen de tabulacion problema 3: no se poner tampoco la ruta del archivo "C:\WINDOWS\system32\drivers\etc\hosts" problema 4: como este archivo es de sistema lo unico que lo habre es el notepad yo lo hago de esta manera con icono directo C:\Windows\notepad.exe "C:\WINDOWS\system32\drivers\etc\hosts" por lo tanto no se me ocurre para que no salte el notepad Formato a si queda escrito el archivo pero no se como hacer para solo escribir la pagina en el testbox , esto es que deberia estar escrito siempre el 127.0.0.1 para solo poner la pagina mala jeje la salida o el archivo Host debe de quedar asi 127.0.0.1 http// es aliexpress com 127.0.0.1 www p wntg2x com 127.0.0.1 http activities aliexpress com 127.0.0.1 http n4uzz super-promo boundaryspot biz / 127.0.0.1 http qjozz super-promo.boundaryspot biz esto es lo que llevo hecho hasta el momento Imports System.IO Public Class Form1 Private TextBoxes As TextBox() = {Nothing} Private N1 As Int32() Private Result1 As Int32() Private _textBox As Object Private Property TextBox(ByVal TextBoxCount As Short) As Object Get Return _textBox End Get Set(ByVal value As Object) _textBox = value End Set End Property ReadOnly Property Num1 As Int32 Get Return CInt(TextBox1.Text) End Get End Property Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Result1 = {Num1} _ Dim rutaFichero As String Dim i As Integer rutaFichero = Path.Combine(Application.StartupPath, "hts.txt") Dim fichero As New IO.StreamWriter(rutaFichero) fichero.Close() End Sub '-------------------------------- Private Sub PaginasBlokeadasToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PaginasBlokeadasToolStripMenuItem.Click Process.Start(Path.Combine(Application.StartupPath, "C:\WINDOWS\system32\drivers\etc\hosts")) End Sub Private Sub SalirToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SalirToolStripMenuItem.Click If MessageBox.Show("Esta seguro que desea Cerrar ", "Cerrar Stop Spam ", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then Me.Close() End If End Sub End Class
Saludos Luis
|
|
|
133
|
Programación / .NET (C#, VB.NET, ASP) / De nuevo con los numeros :)
|
en: 16 Octubre 2015, 19:16 pm
|
Hola Bien gracias a nuestro querido amigo Elektro (que jaleti soy ) tengo este codigo o funcion que funciona bien.pero ahora se me ocurre que en ves de un solo digito con los que se combinan ahora lo quiero hacer de dos digitos . Ahora es con estos {0, 3, 4, 5, 8} pero si pongo {01, 13, 34, 55, 84} No logro hacer lo mismo que con los digitos solos he modificado trasteado pero nada Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim valuesInt As IEnumerable(Of Integer) = {0, 3, 4, 5, 8} {01, 13, 34, 55, 84} <---------usar esto ???? Dim pairs As IEnumerable(Of KeyValuePair(Of Integer, IEnumerable(Of Integer))) = Form1.GetPairs(valuesInt, maxValue:=90) For Each pair As KeyValuePair(Of Integer, IEnumerable(Of Integer)) In pairs ' ListBox1.Items.Add(String.Format("Key: {0,-4} Values: {1}", pair.Key, String.Join(", ", pair.Value))) Next pair Public Shared Function GetPairs(ByVal col As IEnumerable(Of Integer), Optional ByVal maxValue As Integer = Integer.MaxValue) As IEnumerable(Of KeyValuePair(Of Integer, IEnumerable(Of Integer))) If (col.Max >= 10) Then Throw New ArgumentException(paramName:="col", Message:="El valor máximo de la colección debe ser un valor inferior a 10.") Else Return From value As Integer In col Select New KeyValuePair(Of Integer, IEnumerable(Of Integer))( key:=value, value:=From index As Integer In col Where (index <> value) AndAlso (CInt(value & index) <= maxValue) Select CInt(value & index)) End If
Luis
|
|
|
134
|
Programación / .NET (C#, VB.NET, ASP) / Re: Error en variable ???
|
en: 9 Octubre 2015, 15:41 pm
|
SOLUCIONADO Public Class Form1 Dim maxo As Integer = 7 Dim valuesInta As IEnumerable(Of Integer) Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim valuesInt As IEnumerable(Of Integer) = {0, 1, 2, 3, 4, 5, 6, 9} Dim pairs As IEnumerable(Of KeyValuePair(Of Integer, IEnumerable(Of Integer))) = Form1.GetPairs(valuesInt, maxValue:=80) For Each pair As KeyValuePair(Of Integer, IEnumerable(Of Integer)) In pairs ListBox1.Items.Add(String.Format("Key: {0,-4} Values: {1}", pair.Key, String.Join(", ", pair.Value))) Next pair MsgBox(String.Join(", ", pairs(0).Value)) MsgBox(String.Join(", ", pairs(1).Value)) MsgBox(String.Join(", ", pairs(2).Value)) MsgBox(String.Join(", ", pairs(3).Value)) Dim M1 As IEnumerable(Of Integer) = pairs(0).Value.ToList Dim juntos2 As List(Of Integer) = M1 juntos2.Sort() 'Me.ListBox2.Items.AddRange((From value As Integer In M1).Cast(Of Object).ToArray) Dim M2 As IEnumerable(Of Integer) = pairs(1).Value.ToList Dim juntos3 As List(Of Integer) = M2 juntos3.Sort() 'Me.ListBox2.Items.AddRange((From value As Integer In M1).Cast(Of Object).ToArray) Dim M3 As IEnumerable(Of Integer) = pairs(2).Value.ToList Dim juntos4 As List(Of Integer) = M3 juntos4.Sort() Dim M4 As IEnumerable(Of Integer) = pairs(3).Value.ToList Dim juntos5 As List(Of Integer) = M4 juntos5.Sort() Dim cols As IEnumerable(Of IEnumerable(Of String)) = From col As IEnumerable(Of Integer) In {juntos2, juntos3, juntos4, juntos5}.Distinct.ToList Where (col.Count() = maxo) Group By String.Join("", col).AsEnumerable Into Group Select From value As Integer In Group.First.Distinct Select value.ToString(format:="0#") ListBox2.Items.AddRange((From col As IEnumerable(Of String) In cols Select String.Join(", ", col)).ToArray) MsgBox(cols.Count) End Sub Public Shared Function GetPairs(ByVal col As IEnumerable(Of Integer), Optional ByVal maxValue As Integer = Integer.MaxValue) As IEnumerable(Of KeyValuePair(Of Integer, IEnumerable(Of Integer))) If (col.Max >= 10) Then Throw New ArgumentException(paramName:="col", Message:="El valor máximo de la colección debe ser un valor inferior a 10.") Else Return From value As Integer In col Select New KeyValuePair(Of Integer, IEnumerable(Of Integer))( key:=value, value:=From index As Integer In col Where (index <> value) AndAlso (CInt(value & index) <= maxValue) Select CInt(value & index)) End If End Function End Class
Luis
|
|
|
135
|
Programación / .NET (C#, VB.NET, ASP) / Error en variable ???
|
en: 9 Octubre 2015, 10:41 am
|
Estoy trabajno este codigo y me da error en cols y no descubro el porque ? ya que lo declaro ?? Error 2 'cols' no está declarado. Puede que esté inaccesible debido a su nivel de protección. Public Class Form1 Dim maxo As Integer = 7 Dim valuesInta As IEnumerable(Of Integer) Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim valuesInt As IEnumerable(Of Integer) = {0, 1, 2, 3, 4, 5, 6, 9} Dim pairs As IEnumerable(Of KeyValuePair(Of Integer, IEnumerable(Of Integer))) = Form1.GetPairs(valuesInt, maxValue:=80) For Each pair As KeyValuePair(Of Integer, IEnumerable(Of Integer)) In pairs ListBox1.Items.Add(String.Format("Key: {0,-4} Values: {1}", pair.Key, String.Join(", ", pair.Value))) Next pair MsgBox(String.Join(", ", pairs(0).Value)) MsgBox(String.Join(", ", pairs(1).Value)) MsgBox(String.Join(", ", pairs(2).Value)) MsgBox(String.Join(", ", pairs(3).Value)) Dim M1 As IEnumerable(Of Integer) = pairs(0).Value.ToList Dim juntos2 As List(Of Integer) = M1 juntos2.Sort() Me.ListBox2.Items.AddRange((From value As Integer In M1).Cast(Of Object).ToArray) Dim M2 As IEnumerable(Of Integer) = pairs(1).Value.ToList Dim juntos3 As List(Of Integer) = M2 juntos3.Sort() 'Me.ListBox2.Items.AddRange((From value As Integer In M1).Cast(Of Object).ToArray) Dim M3 As IEnumerable(Of Integer) = pairs(2).Value.ToList Dim juntos4 As List(Of Integer) = M3 juntos4.Sort() Dim M4 As IEnumerable(Of Integer) = pairs(3).Value.ToList Dim juntos5 As List(Of Integer) = M4 juntos5.Sort() End Sub Public Shared Function GetPairs(ByVal col As IEnumerable(Of Integer), Optional ByVal maxValue As Integer = Integer.MaxValue) As IEnumerable(Of KeyValuePair(Of Integer, IEnumerable(Of Integer))) If (col.Max >= 10) Then Throw New ArgumentException(paramName:="col", Message:="El valor máximo de la colección debe ser un valor inferior a 10.") Else Return From value As Integer In col Select New KeyValuePair(Of Integer, IEnumerable(Of Integer))( key:=value, value:=From index As Integer In col Where (index <> value) AndAlso (CInt(value & index) <= maxValue) Select CInt(value & index)) End If End Function Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim cols As IEnumerable(Of IEnumerable(Of String)) = From col As IEnumerable(Of Integer) In {juntos2, juntos3, juntos4, juntos5}.Distinct.ToList Where (col.Count() = maxo) Group By String.Join("", col).AsEnumerable Into(Group) Select From value As Integer In Group.First.Distinct Select value.ToString(format:="0#") Me.ListBox2.Items.AddRange((From cols As IEnumerable(Of String) In cols Select String.Join(", ", col)).ToArray) [color=red]<-----ACA ME DA EL ERROR[/color] ' MsgBox(cols.Count) End Sub End Class
se supone que ya lo declaro y en otro codigo si me funciona bien luis
|
|
|
136
|
Programación / .NET (C#, VB.NET, ASP) / Re: De nuevo con los filtros
|
en: 8 Octubre 2015, 16:35 pm
|
Creo a si van los tiros Dim M1 As IEnumerable(Of Integer) = pairs(1).Value.ToList Dim juntos2 As List(Of Integer) = M1 juntos2.Sort() Me.ListBox2.Items.AddRange((From value As Integer In M1).Cast(Of Object).ToArray)
Ya listo Luis
|
|
|
137
|
Programación / .NET (C#, VB.NET, ASP) / Re: De nuevo con los filtros
|
en: 7 Octubre 2015, 15:08 pm
|
Lo tienes perfecto tal y como está, es más productivo así. Creo que solo necesitas un ejemplo de cómo usar el índice (no deberías necesitar un ejemplo a estas alturasss), como el siguiente, por que yo no le veo ninguna dificultad de accesibilidad adicional entre hacer esto: ' Dim pairs As IEnumerable(Of KeyValuePair(Of Integer, IEnumerable(Of Integer))) = ... MsgBox(String.Join(", ", pairs(0).Value))
...o hacer esto otro: ' Dim col As IEnumerable(Of IEnumerable(Of Integer)) = ... MsgBox(String.Join(", ", col(0)))
Para hacer lo segundo, cosa que repito ...es innecesario, pero bueno, tendrías que modificar el tipo de objeto que maneja la función, para devolver un IEnumerable(Of IEnumerable(Of Integer)) claro está... Saludos! Hola bien es que la idea de tener cada key o valor dentro de una variable es por ejemplo pongamos el 0 : Key: 0 Values: 1, 2, 4, 5, 6, 7, 8 nesecitaria dado el caso hacer combinaciones con la clave o key 2 key 2 values: 20, 21, 24, 25, 26, 27, 28 ejemplo si los concateno key 0 + key 2 = 1, 2, 4, 5, 6, 7, 8 ,20, 21, 24, 25, 26, 27, 28 No nesecito que esten todos los numeros en una variable, si no cada grupo en su respectiva variable para yo poder hacer calculos con cada una o entre ellas Luis
|
|
|
138
|
Programación / .NET (C#, VB.NET, ASP) / Re: De nuevo con los filtros
|
en: 7 Octubre 2015, 13:58 pm
|
Bueno sigo con mis enredos aunque ya esta resuelta la pregunta ahora me encuentro en otra dimension desconocida jejej se como se convierten ya las variables pero no de este tipo codigo Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim valuesInt As IEnumerable(Of Integer) = {0, 1, 2, 4, 6, 7, 8} Dim pairs As IEnumerable(Of KeyValuePair(Of Integer, IEnumerable(Of Integer))) = Form1.GetPairs(valuesInt, maxValue:=80) For Each pair As KeyValuePair(Of Integer, IEnumerable(Of Integer)) In pairs ListBox1.Items.Add(String.Format("Key: {0,-4} Values: {1}", pair.Key, String.Join(", ", pair.Value))) Next pair End Sub Public Shared Function GetPairs(ByVal col As IEnumerable(Of Integer), Optional ByVal maxValue As Integer = Integer.MaxValue) As IEnumerable(Of KeyValuePair(Of Integer, IEnumerable(Of Integer))) If (col.Max >= 10) Then Throw New ArgumentException(paramName:="col", message:="El valor máximo de la colección debe ser un valor inferior a 10.") Else Return From value As Integer In col Select New KeyValuePair(Of Integer, IEnumerable(Of Integer))( key:=value, value:=From index As Integer In Enumerable.Range(1, 9) Where (index <> value) AndAlso (CInt(value & index) <= maxValue) Select CInt(value & index)) End If End Function End Class
esto entrega estos resultados y quiero pasarlos a unas variables normalitas jejje Key: 0 Values: 1, 2, 4, 5, 6, 7, 8 Key: 1 Values: 10, 12, 14, 15, 16, 17, 18 Key: 2 Values: 20, 21, 24, 25, 26, 27, 28 Key: 4 Values: 40, 41, 42, 45, 46, 47, 48 Key: 5 Values: 50, 51, 52, 54, 56, 57, 58 Key: 6 Values: 60, 61, 62, 64, 65, 67, 68 Key: 7 Values: 70, 71, 72, 74, 75, 76, 78 Key: 8 Values: 80, 81, 82, 84, 85, 86, 87 como puedo meter en cada variable los valores de cada key ejemplo variable 0 = 1, 2, 4, 5, 6, 7, 8 variable 1= 10, 12, 14, 15, 16, 17, 18 variable 2= 20, 21, 24, 25, 26, 27, 28 Luis
|
|
|
139
|
Programación / .NET (C#, VB.NET, ASP) / Re: De nuevo con los filtros
|
en: 4 Octubre 2015, 21:57 pm
|
Retomando la función que te mostré aquí: http://foro.elhacker.net/net/formar_pares_de_numeros-t442316.0.html;msg2041620#msg2041620Le puedes añadir un parámetro opcional para limitar el valor máximo que se debe devolver. Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim [color=yellow]valuesInt[/color] As IEnumerable(Of Integer) = {0, 1, 4, 6, 2, 8, 7} Dim pairs As IEnumerable(Of KeyValuePair(Of Integer, IEnumerable(Of Integer))) = Form1.GetPairs(valuesInt, maxValue:=50) For Each pair As KeyValuePair(Of Integer, IEnumerable(Of Integer)) In pairs ListBox1.Items.Add(String.Format("Key: {0,-4} Values: {1}", pair.Key, String.Join(", ", pair.Value))) Next pair End Sub Public Shared Function GetPairs(ByVal col As IEnumerable(Of Integer), Optional ByVal maxValue As Integer = Integer.MaxValue) As IEnumerable(Of KeyValuePair(Of Integer, IEnumerable(Of Integer))) If (col.Max >= 10) Then Throw New ArgumentException(paramName:="col", message:="El valor máximo de la colección debe ser un valor inferior a 10.") Else Return From value As Integer In col Select New KeyValuePair(Of Integer, IEnumerable(Of Integer))( key:=value, value:=From index As Integer In Enumerable[color=red].Range(1, 9)[/color] Where (index <> value) AndAlso (CInt(value & index) <= maxValue) Select CInt(value & index)) End If End Function End Class
Saludos Hola Elektro No te habia respondido porque me quede dormido jejej ,bien tengo el siguiente problema con esto, ya en el anterior lo habia resuelto pero en este no se, como sabes los numeros de la variable valuesIn no mantienen la misma cantidad de numeros en cada ejecucion y estos varian. en donde esta lo de Range(1, 9) aunque en la variable haya menos numeros me toma como que si hubieran los 9 siempre Como siempre gracias Luis edicto jejej creo lo resolvi pero corrigeme si estoy pelado Return From value As Integer In col Select New KeyValuePair(Of Integer, IEnumerable(Of Integer))( key:=value, value:=From index As Integer In col Where (index <> value) AndAlso (CInt(value & index) <= maxValue) Select CInt(value & index))
|
|
|
140
|
Programación / .NET (C#, VB.NET, ASP) / De nuevo con los filtros
|
en: 4 Octubre 2015, 12:33 pm
|
Hola Recien resolvi o mejor dicho me resolvieron unas dudas gracias a como siempre elektro jejej ahora vengo de nuevo con algo que lo mejor es una bobera pero ya me volvi loco buscando la solucion Explico tengo este codigo Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim valuesInt As IEnumerable(Of Integer) = {0, 1, 4, 6, 2, 8, 7} Dim pairs As IEnumerable(Of KeyValuePair(Of Integer, IEnumerable(Of Integer))) = From value As Integer In valuesInt Select New KeyValuePair(Of Integer, IEnumerable(Of Integer))( key:=value, value:=From index As Integer In valuesInt Where index <> Integer.Parse(CStr(value).Last) Select CInt(value & index)) For Each pair As KeyValuePair(Of Integer, IEnumerable(Of Integer)) In pairs ListBox1.Items.Add(String.Format("Key: {0,-4} Values: {1}", pair.Key, String.Join(", ", pair.Value))) Next pair End Sub End Class
lo que no puedo hacer una limitacion de los resultados o sea que si los numeros muestran del 01 al 89 y yo quiera mostrar solo desde el 01 al 50 ,no se ya que tampoco he logrado pasar estos resultados a otra variable que yo pueda o conosca manejar ya que con "pair.Key " no tengo ide de como manejar esto . Luis
|
|
|
|
|
|
|