miércoles, 13 de marzo de 2024

Buscar por Codigo de Barras en Excel con VB .Net 2022

Tabla Excel
Imports Microsoft.Office.Interop

Public Class frmGrid3

Dim Aplicacion As Excel.Application

Dim Libro As Excel.Workbook

Dim hoja As Excel.Worksheet

Private Sub frmGrid3_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        cargarLibro()

End Sub

Private Sub cargarLibro()

    DataGridView1.ColumnCount = 3

    DataGridView1.Columns(0).Name = "Bar Code"

    DataGridView1.Columns(1).Name = "Producto"

    DataGridView1.Columns(2).Name = "Precio"

    DataGridView1.Columns(1).Width = 200

    Aplicacion = New Excel.Application

    Libro = Aplicacion.Workbooks.Open("C:\Users\miky mouse\OneDrive\ejemplo5.xlsx")

    hoja = Libro.Worksheets(2)

End Sub

Private Sub frmGrid3_Closed(sender As Object, e As EventArgs) Handles MyBase.Closed

        Libro.Close()

        Aplicacion.Quit()

End Sub

Private Sub TextBox1_KeyDown(sender As Object, e As KeyEventArgs) Handles TextBox1.KeyDown

        Dim bc As String

        Dim dato(3) As String

        If e.KeyCode = 13 Then

            bc = TextBox1.Text

            For i = 2 To 23

                If bc = hoja.Cells(i, 1).Value Then

                    dato(0) = hoja.Cells(i, 1).value

                    dato(1) = hoja.Cells(i, 2).value

                    dato(2) = hoja.Cells(i, 3).value

                    DataGridView1.Rows.Add(dato)

                End If

            Next

            MsgBox("enter " + bc)

        End If

    End Sub

End Class

minuvaSoft10@gmail.com
download source code


sábado, 9 de marzo de 2024

Leer y Agregar en Excel con Visual Basic .Net 2022

Imports Microsoft.Office.Interop.Excel

Private Sub LeerExcel()

    Dim Aplicacion As Excel.Application

    Dim Libro As Excel.Workbook

    Dim hoja As Excel.Worksheet

    Dim cad As String

    Aplicacion = New Excel.Application

    Libro = Aplicacion.Workbooks.Open("C:\Users\miky mouse\OneDrive\ejemplo3.xlsx")

    hoja = Libro.Worksheets(1)

    cad = hoja.Cells(3, 5).Value   ' Lee de hoja 1 fila 3 y columna5

    MsgBox("dato=" + cad)

    hoja.Cells(8, 1).value = "9876.65"   'Agrega en hoja 1 el dato, en fila 8 y columna 1

    Libro.Close()

    Aplicacion.Quit()

End Sub



martes, 5 de marzo de 2024

DataGridView Agregar Obtener Eliminar Filas con Visual Basic 2022

Public Class frmGrid

    Private Sub frmGrid_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        carga()

    End Sub

    Private Sub carga()

        DataGridView1.ColumnCount = 4

        DataGridView1.Columns(0).Name = "Marca"

        DataGridView1.Columns(1).Name = "Modelo"

        DataGridView1.Columns(2).Name = "Year"

        DataGridView1.Columns(3).Name = "MSRP"

        Dim dato(4) As String

        dato(0) = "Toyota"

        dato(1) = "Prius"

        dato(2) = "2020"

        dato(3) = "18000"

        DataGridView1.Rows.Add(dato)

        dato(0) = "Toyota"

        dato(1) = "RAV 4"

        dato(2) = "2019"

        dato(3) = "19000"

        DataGridView1.Rows.Add(dato)

        dato(0) = "Toyota"

        dato(1) = "HighLander"

        dato(2) = "2018"

        dato(3) = "19555"

        DataGridView1.Rows.Add(dato)

        dato(0) = "Dodge"

        dato(1) = "Charger"

        dato(2) = "2017"

        dato(3) = "18555"

        DataGridView1.Rows.Add(dato)

    End Sub

    Private Sub btnObtener_Click(sender As Object, e As EventArgs) Handles btnObtener.Click

        txtPrecio.Text = DataGridView1.Item(3, 2).Value

    End Sub

    Private Sub btnFila_Click(sender As Object, e As EventArgs) Handles btnFila.Click

        Dim cad As String

        cad = DataGridView1.SelectedRows(0).Cells(0).Value + DataGridView1.SelectedRows(0).Cells(1).Value

        cad += DataGridView1.SelectedRows(0).Cells(2).Value + DataGridView1.SelectedRows(0).Cells(3).Value

        txtPrecio.Text = cad

    End Sub

Private Sub btnEliminar_Click(sender As Object, e As EventArgs) Handles btnEliminar.Click

        DataGridView1.Rows.RemoveAt(2)

    End Sub

End Class



viernes, 1 de marzo de 2024

Graficar Funcion Cuadratica Ingresando Coheficientes con Matplotlib y Python

import tkinter as tk
from tkinter import ttk
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib.figure import Figure
import numpy as np
def graf():
    fig = Figure(figsize=(5, 4), dpi=100)
    t = np.arange(-3, 3, .01)
   
    a = eval(entry1.get())
    b = eval(entry2.get())
    c = eval(entry3.get())
   
    fig.add_gridspec(True)
    fig.add_subplot(111).plot(t, a*t**2+b*t+c,'o:g')
   
    canvas = FigureCanvasTkAgg(fig, master=root)
    canvas.draw()
    canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)

if __name__ == '__main__':
    # Ventana principal
    root = tk.Tk()
    root.title("Graficar Funcion")
    root.geometry("700x700")    
   
    # Coheficiente 1
    dato1=tk.StringVar()
    entry1=ttk.Entry(root, textvariable=dato1, width=5)
    entry1.place(x=5, y=5)
    lblCo1 = tk.Label(root,text="X^2 +")
    lblCo1.place(x=45,y=5)

    # Coheficiente 2
    dato2=tk.StringVar()
    entry2=ttk.Entry(root, textvariable=dato2, width=5)
    entry2.place(x=100, y=5)
    lblCo2 = tk.Label(root,text="X +")
    lblCo2.place(x=150,y=5)

    # Coheficiente 3
    dato3=tk.StringVar()
    entry3=ttk.Entry(root, textvariable=dato3, width=5)
    entry3.place(x=200, y=5)
   
    # Boton
    button = tk.Button(root, text="Graficar", command=graf)
   
    button.pack()
    # Iniciar el bucle principal de la aplicación
    root.mainloop()
download source code



 

lunes, 26 de febrero de 2024

Graficar Funcion Seno con Visual Basic 2022

De la caja de herramientas agregar un picturebox, un boton y un listbox.

Private Sub btnSeno_Click(sender As Object, e As EventArgs) Handles btnSeno.Click

    Dim brush As New SolidBrush(Color.Blue)

    Dim papel As Graphics = PictureBox1.CreateGraphics()

    Dim i, x, y As Single

    For i = 0 To 20 Step 0.05

        If (i + 200) > PictureBox1.Width Then

            Exit For

        End If

        y = Math.Sin(i)

        ListBox1.Items.Add(y)

        x = i * 30 + 50

        papel.FillEllipse(brush, x, (y * 150) + 200, 10, 10)

        Thread.Sleep(1000)

    Next

End Sub

download source code


sábado, 24 de febrero de 2024

Graficar 2 Funciones en una Figura con Matplotlib y Python

import matplotlib.pyplot as plt

import numpy as np

t = np.linspace(-2,2,1000)

y1 = t**3+2*t**2-1

y2 = t**3 + t**2 - t 

plt.axhline(0, color='black')

plt.axvline(0, color='black')

plt.xlabel('t')

plt.ylabel('y')

plt.plot(t,y1,'o:b',t,y2,'o:g')

plt.grid(True)

plt.show()

minuvasoft10@gmail.com


sábado, 17 de febrero de 2024

Agregar RadioButton y Obtener su Valor con Visual Basic 2022

 De la caja de herramientas agregar un groupbox

Agregar 4 radiobutton en groupbox
Private Sub btnEnviar_Click(sender As Object, e As EventArgs) Handles btnEnviar.Click
    Dim cad As String
    If RadioButton3.Checked = True Then
        cad = "Soltero"
    End If
    If RadioButton4.Checked = True Then
        cad = "Casado"
    End If
    If RadioButton5.Checked = True Then
        cad = "Divorciado"
    End If
    If RadioButton6.Checked = True Then
        cad = "Viudo"
    End If
    MessageBox.Show("Su estado civil es " + cad)
End Sub
minuvasoft10@gmail.com






Conectar a MySql con Java Netbeans mediante un Formulario

 Tener agregado en libraries el conector mysql. clase coneBD.java package pktForm12; import java.sql.*; import javax.swing.JOptionPane; publ...