|
9981
|
Programación / .NET (C#, VB.NET, ASP) / Re: [APORTE] Snippets
|
en: 19 Diciembre 2012, 04:04 am
|
$Edu$ no se si tienes el VS pero si lo tienes donde escribes el código del form presiona " click derecho > insert snippet" y ahí ves lo que són. Esto de snippets vendria a ser como "codigos sueltos" para poder copiar y tenerlos a mano siempre? Ya te ha contestado Novlucker pero cabe decir que un snippet no es algo que haya inventado Microsoft, hay bastantes editores de texto que soportan el uso de snippets, y bueno... los que trabajen con HTML/CSS/PHP y todo eso seguro que están muy acostumbrados a usar snippets para sus diseños web, igual que se pueden tener snippets para Batch (xD). saludos!
tal vez deberías de tener snippets que hagan las cosas de la manera más elegante y "performante" posible , hay código mejorable Hay algunos snippets que yo solo no podría haberlos creado porque no sé hacerlo, por ejemplo el " GlobalHotkeys.snippet", no véas cuanto código con las APIs, como para ponerme a intentar mejorarlos! Ahora te hago yo una sugerencia: De sabios es compartir el conocimiento, hay que realizar buenas acciones antes de que se acabe el munedo en... 2 días , Y lo que necesita todo aprendiz de programador es un aporte con los snippets del gran Nov, muchos lo agradecerían (O al menos uno aquí presente... xD). Ahí lo dejo... Saludos!
|
|
|
9982
|
Programación / .NET (C#, VB.NET, ASP) / Re: XmlDocument.LoadXml ¿Porque no me funciona?
|
en: 18 Diciembre 2012, 22:30 pm
|
Nada Nov, no quiere funcionar... no me salta ninguna excepción. Lo de "Load" lo había visto pero como me decía que era para una URL... xD lo he intentado con load y la app se cuelga en donde la excepción, pero no me manda ningún error, juas. EDITO: Vale, ahora sí me salta excepción... "There are multiple root elements. Line 2, position 2." ¿Porque me dice que hay multiples elementos, si en teoría de lo que se trata es de obtener multiples elementos del mismo TagName xD? Try xmlDoc.Load("C:\t.xml") Catch ex As Exception MessageBox.Show(ex.Message) End Try
t.xml: <name>1</name> <name>2</name> <name>3</name> <name>4</name>
|
|
|
9984
|
Programación / Scripting / Re: libro "python para todos" equivalencia en un curriculum
|
en: 18 Diciembre 2012, 22:16 pm
|
¿Cuanto tiempo le veis a un menor un poco mas inteligente que la media aprender Java, C, C++, HTML, javascript, PHP, CSS y SQL a nivel medio? Has hecho un comentario fuera de lugar, Si tienes una duda que no séa referente al tema que se está tranando en este hilo entonces formula tu pregunta en un nuevo post. Pero ya puestos te aconsejo empezar con HTML para que te lo quites de encima bien rápido, ya que se aprende en menos de 7 días (Es un lenguaje de etiquetas), yo sé lo básico sólamente habiendo mirado el nombre de todos los tags 2 o 3 veces, y bueno, el resto te lo hace el DW xD. PD: No sigas el tema porfavor. Saludos.
|
|
|
9985
|
Programación / .NET (C#, VB.NET, ASP) / XmlDocument.LoadXml ¿Porque no me funciona?
|
en: 18 Diciembre 2012, 20:43 pm
|
- ¿Porque no me funciona? - ¿Y se puede cargar un archivo xml local sin setearlo en un string? Imports System.Xml Imports System.Xml.Serialization Imports System.IO Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim rawXML As String = _ "<Company>" & _ " <Employee>" & _ " <name>John</name>" & _ " <Id>1</Id>" & _ " <email>John@xxxxxx.com</email>" & _ " </employee>" & _ " <employee>" & _ " <name>Sue</name>" & _ " <Id>2</Id>" & _ " <email>Sue@xxxxxx.com</email>" & _ " </employee>" & _ "</Company>" Dim xmlDoc As New XmlDocument Dim employeeNodes As XmlNodeList Dim employeeNode As XmlNode Dim baseDataNodes As XmlNodeList Dim bFirstInRow As Boolean MsgBox("A") xmlDoc.LoadXml(rawXML) ' Este msgbox no se llega a ver MsgBox("B") employeeNodes = xmlDoc.GetElementsByTagName("name") For Each employeeNode In employeeNodes baseDataNodes = employeeNode.ChildNodes bFirstInRow = True For Each baseDataNode As XmlNode In baseDataNodes If (bFirstInRow) Then bFirstInRow = False Else MsgBox(", ") End If MsgBox(baseDataNode.Name & ": " & baseDataNode.InnerText) Next Next End Sub End Class
|
|
|
9986
|
Programación / Scripting / Re: Habilitar conexión compartida a internet (ICS) con visual basic script
|
en: 18 Diciembre 2012, 20:16 pm
|
PD : es un reto para todos los que les gusta la programación en scripting y sobre todo los retos. Para que molestarse en codearlo cuando ya está hecho xD. Pruébalo pasándole los argumentos necesarios: Originally from http://www.autoitscript.com/forum/topic/28897-switch-ics/ 'Changed to VBS, added arguments and fixed for private/public networkds by Dror Gluska 2012-06-25 'Dror Gluska (2012) - http://uhurumkate.blogspot.co.il/ option explicit Main( ) sub Main( ) dim objArgs, con, endis,con2 Set objArgs = WScript.Arguments 'WScript.Echo objArgs.Count if objArgs.Count > 0 then con = objArgs(0) con2 = objArgs(1) endis = objArgs(2) EnableDisableICS con,con2, endis 'true enables, false disables else DIM szMsg szMsg = "Invalid usage! Please provide the name of the connection as the argument." & vbCRLF & vbCRLF & _ "Usage:" & vbCRLF & _ " " + WScript.scriptname + " ""Public Connection Name"" ""Private Connection Name"" true/false" WScript.Echo( szMsg ) end if end sub function EnableDisableICS(sPublicConnectionName, sPrivateConnectionName, bEnable) dim bFound bFound = FALSE dim oNetSharingManager, oConnectionCollection, oItem, EveryConnection, objNCProps set oNetSharingManager = Wscript.CreateObject("HNetCfg.HNetShare.1") if (IsObject(oNetSharingManager)) = FALSE then Wscript.Echo("Unable to get the HNetCfg.HnetShare.1 object.") Exit function End if if (IsNull(oNetSharingManager.SharingInstalled) = TRUE) then Wscript.Echo( "Sharing is not available on this platform.") Exit function End if set oConnectionCollection = oNetSharingManager.EnumEveryConnection for each oItem In oConnectionCollection set EveryConnection = oNetSharingManager.INetSharingConfigurationForINetConnection (oItem) set objNCProps = oNetSharingManager.NetConnectionProps (oItem) If objNCProps.name = sPrivateConnectionName Then bFound = True Wscript.Echo("Setting ICS Private to " & bEnable & " on connection: " & objNCProps.name) If bEnable Then EveryConnection.EnableSharing (1) Else EveryConnection.DisableSharing End if End if Next set oConnectionCollection = oNetSharingManager.EnumEveryConnection for each oItem In oConnectionCollection set EveryConnection = oNetSharingManager.INetSharingConfigurationForINetConnection (oItem) set objNCProps = oNetSharingManager.NetConnectionProps (oItem) If objNCProps.name = sPublicConnectionName Then bFound = True Wscript.Echo("Setting ICS Public to " & bEnable & " on connection: " & objNCProps.name) If bEnable Then EveryConnection.EnableSharing (0) Else EveryConnection.DisableSharing End if End if next If Not bFound Then Wscript.Echo("Unable to find the connection " & sPublicConnectionName) End if end function
|
|
|
9987
|
Programación / .NET (C#, VB.NET, ASP) / Re: Duda sobre los elementos que trabajan en segundo plano
|
en: 18 Diciembre 2012, 18:14 pm
|
'Declaration Public Delegate Sub Action(Of In T1, In T2, In T3, In T4, In T5, In T6, In T7, In T8, In T9, In T10, In T11, In T12, In T13, In T14, In T15, In T16) ( _ arg1 As T1, _ arg2 As T2, _ arg3 As T3, _ arg4 As T4, _ arg5 As T5, _ arg6 As T6, _ arg7 As T7, _ arg8 As T8, _ arg9 As T9, _ arg10 As T10, _ arg11 As T11, _ arg12 As T12, _ arg13 As T13, _ arg14 As T14, _ arg15 As T15, _ arg16 As T16 _ )
Eso ya pinta dificil. PREGUNTA: ¿Action tiene un límite de 16 argumentos? (Quizás no llegue a saber hacer eso en toda mi vida xD, pero estaría bien saberlo si se da el caso.) De todas formas con toda esta info doy por solucionado el tema xD, Gracias por vuestras respuestas.
Bonito snippet: Simple Delegate Example Imports System Namespace DelegateTest Public Delegate Sub TestDelegate(ByVal message As String) Class Program Public Shared Sub Display(ByVal message As String) Console.WriteLine("") Console.WriteLine("The string entered is : " + message) End Sub Shared Sub Main(ByVal args As String()) '-- Instantiate the delegate Dim t As New TestDelegate(AddressOf Display) '-- Input some text Console.WriteLine("Please enter a string:") Dim message As String = Console.ReadLine() '-- Invoke the delegate t(message) Console.ReadLine() End Sub End Class End Namespace
|
|
|
9989
|
Programación / .NET (C#, VB.NET, ASP) / Re: Duda sobre los elementos que trabajan en segundo plano
|
en: 18 Diciembre 2012, 16:07 pm
|
¿Y que me dicen de esto? ' Usage: ' InvokeControl(RichTextBox1, Sub(x) x.AppendText("a")) #Region " Invoke Controls " Public Sub InvokeControl(Of T As Control)(ByVal Control As T, ByVal Action As Action(Of T)) If Control.InvokeRequired Then Control.Invoke(New Action(Of T, Action(Of T))(AddressOf InvokeControl), New Object() {Control, Action}) Else Action(Control) End If End Sub #End Region
Lo he testeado a fondo creando varios threads que modifican propiedades de varios controles al mismo tiempo, e incluso modifican el mismo control del form principal todos los threads al mismo tiempo, y no me ha saltado ninguna excepción, es decir, lo he podido usar sin escribir delegados... ¿Esa técnica la consideran buena o la idea de usar delegados sigue siendo mejor?
|
|
|
9990
|
Programación / .NET (C#, VB.NET, ASP) / (SOLUCIONADO) ¿Que tipo de parámetro debo pasarle?
|
en: 18 Diciembre 2012, 15:11 pm
|
EDITO: Esto ya no necesito saberlo
Module InvokeRequiredHandler <System.Runtime.CompilerServices.Extension()> _ Public Sub HandleInvokeRequired(Of T As ISynchronizeInvoke)(ByVal controlToInvoke As T, ByVal actionToPerform As Action(Of T)) 'Check to see if the control's InvokeRequired property is true If controlToInvoke.InvokeRequired Then 'Use Invoke() to invoke your action controlToInvoke.Invoke(actionToPerform, New Object() {controlToInvoke}) Else 'Perform the action actionToPerform(controlToInvoke) End If End Sub End Module
Si por ejemplo, desde otro hilo quisiera modificar la propiedad "Text" de un textbox... ¿Como lo hago? HandleInvokeRequired(Textbox1, ¿?) No se que argumento se puede usar como "Action"
|
|
|
|
|
|
|