Archive for Octubre, 2008
Visual Basic 6.0 - Ejecutar una aplicación desde la Shell
Written by lopezatienza on 29 Octubre 2008 – 16:54 -Dim lWait As Long
Dim bProceed As Boolean
Dim LRet As Long
Dim sMessage As String
Dim sPROCESS_INFORMATION As String
Dim hProcess As Long
Dim hThread As Long
Dim dwProcessId As Long
Dim dwThreadId As Long
Tags: Visual Basic 6.0
Posted in Visual Basic 6.0 | No Comments »
ASP.NET - Aplicación Web Multidioma
Written by lopezatienza on 29 Octubre 2008 – 16:51 -Para ello una vez que tengamos hecha la web, hacer doble click en la página que queremos hacer multidioma y en el menú herramientas darle a Generar recurso local se nos generará un archivo de recurso en la carpeta App_LocalResources parecido a Default.aspx.resx, ahora debemos copiar ese archivo, pegarlo y cambiarle el nombre a Default.aspx.es-es.resx, Default.aspx.en-us.resx, etc.
El que generó automáticamente será el predeterminado y a partir de ahí es para cada idioma, solo tenemos que editar el archivo de recursos de cada idioma para ser multidioma.
Al igual que en Windows Forms lo podemos hacer reutilizable.
Tags: ASP.NET
Posted in ASP.NET | No Comments »
ASP - Configurar aplicación web en IIS
Written by lopezatienza on 29 Octubre 2008 – 16:50 -1. Instalar IIS accediendo a Agregar o Quitar Programas del Panel de control
2. Agregar o quitar componentes de Windows
3. Seleccionar Servicios de Internet Information Server y pulsar Siguiente
4. Copiar nuestro proyecto en la raíz de C:\Inetpub\wwwroot\
5. Inicio\ejecutar -> inetmgr o Acceder a Panel de control \ Herramientas Administrativas \ Servicios de Internet Information Server
6. Desde el arbol de consola acceder al equipo local \ Sitios Web \ Nuestroproyecto
7. Boton derecho -> Propiedades
8. En la pestaña de Directorio click en Crear
9. Introducir el nombre de la aplicación como queramos
10. Boton derecho -> Todas las tareas -> Asistente de permisos
11. En la pantalla de Asistente de permisos realizamos:
11.1 Seleccionar la nueva configuración de seguridad desde una plantilla -> Siguiente
11.2 Seleccionar en Escenario: Public Web Site -> Siguiente
11.3 Reemplazar todos los permisos de directorios y archivos -> Siguiente
11.4 Aparece toda la configuración -> Siguiente
11.5 Finalizar
Tags: ASP
Posted in ASP | No Comments »
CSharp - Incrementar número hexadecimal
Written by lopezatienza on 29 Octubre 2008 – 16:47 -
public string IncrementarHexadecimal(string Numero)
{
try
{
int aux = Numero.Length;
int i = 1;
string Numero2 = "";
while (Numero.Substring(aux - i, 1) == "F")
{
Numero2 = "0" + Numero2;
i++;
}
Tags: C#, CSharp
Posted in CSharp | No Comments »
CSharp - Incrementar String como si fuera numerico
Written by lopezatienza on 29 Octubre 2008 – 16:46 -Esta función te devuelve null si hay algún fallo, por ejemplo que se le pase una cadena con letras.Si se le envía un String que está formado por valores numéricos devolverá 1 número mas de éste.
public string Incrementar(string Numero)
{
try
{
int aux = Numero.Length;
int i = 1;
string Numero2 = "";
while (Numero.Substring(aux - i, 1) == "9")
{
Numero2 = "0" + Numero2;
i++;
}
Numero2 = Convert.ToString(Convert.ToInt32(Numero.Substring(aux - i, 1)) + 1) + Numero2;
Numero2 = Numero.Substring(0, aux - i) + Numero2;
return Numero2;
}
catch { return null; }
}
Read more »Tags: C#, CSharp
Posted in CSharp | No Comments »
CSharp - Diferencia de Fechas
Written by lopezatienza on 29 Octubre 2008 – 16:44 -Este ejemplo devolverá el total de segundos que hay de diferencia entre dos fechas:
DateTime inicio = DateTime.Now;
// EJECUCIÓN de un proceso
DateTime final = DateTime.Now;
TimeSpan duracion = final - inicio;
double segundosTotales = duracion.TotalSeconds; // Calcula la diferencia en segundos, por ejemplo si ha pasado 1:30 contará 90 segundos
int segundos = duracion.Seconds; // Este es un error frecuente, ya que si ha pasado 1:30 segundos no contaría 90, sino 30
Posted in CSharp | No Comments »
CSharp - Formato de Fechas
Written by lopezatienza on 29 Octubre 2008 – 16:42 -// Format : 07 / 03 / 2004
formattedDate = DateTime.Now.ToString("dd / MM / yyyy");
// Format : 7 / 3 / 2004 (without the preceding zeroes)
formattedDate = DateTime.Now.ToString("d / M / yyyy");
// Format : 07 / Mar / 2004
formattedDate = DateTime.Now.ToString("dd / MMM / yy");
// How to get the name of the day ?
// Format : Wednesday
formattedDate = DateTime.Today.DayOfWeek.ToString();
Posted in CSharp | No Comments »
CSharp - Escribir en un fichero sin borrar lo existente
Written by lopezatienza on 29 Octubre 2008 – 16:37 -System.IO.FileStream FS;
System.IO.StreamWriter SW;
string Fichero = Application.StartupPath + @"\Fichero.txt";
FS = new System.IO.FileStream(Fichero, System.IO.FileMode.Append, System.IO.FileAccess.Write);
SW = new System.IO.StreamWriter(FS);
SW.WriteLine("Texto que deseamos introducir");
SW.Close();
Posted in CSharp | No Comments »
CSharp - Leer archivos
Written by lopezatienza on 29 Octubre 2008 – 16:32 -Crearemos un proyecto Windows Form en CSharp llamado LeerArchivo
using System;
using System.IO;
class LeerArchivo {
publicstaticvoid Main()
{
try
{
// Crear una instancia de StreamReader para leer desde un archivo.
// La asignación también cerrará el StreamReader.
using (StreamReader sr = new StreamReader("TestFile.txt"))
String linea;
// Lee y muestra las líneas desde el archivo hasta su fin
while ((linea = sr.ReadLine()) != null)
{
Console.WriteLine(linea);
}
}
}
catch (Exception e)
{
// Let the user know what went wrong.
Console.WriteLine("El fichero no puede ser leído:");
Console.WriteLine(e.Message);
}
}
Posted in CSharp | No Comments »
Visual Basic - Factorial de un numero Recursivo
Written by lopezatienza on 29 Octubre 2008 – 16:17 -Primeramente crearemos nuestro proyecto.
Añadiremos 2 TextBox llamados "textbox1" y "textbox2".
Añadiremos un Button llamado "button1"
Añadiremos el siguiente código a nuestro "Form1.vb"
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim act, res As Double
Dim ant As Integer
act = textbox1.Text
ant = act - 1
Do
res = fact(act, ant)
act = res
ant -= 1
Loop While (ant > 0)
textbox2.Text = res
End Sub
Private Function fact(ByVal act As Double, ByVal ant As Integer) As Double
fact = act * ant
End Function
End Class
Asociar el evento Click del botón Button1 a la función Button1_Click o añade el código directamente.
Un saludo y espero que os sirva de ayuda.
Tags: Visual Basic
Posted in Visual Basic .NET | 5 Comments »
