Quantcast
Channel: VBForums
Viewing all 42124 articles
Browse latest View live

[RESOLVED] Need help to feed textbox array

$
0
0
Hello experts of vbforums
I want to develop a planner and I 'm completely stuck at populating my 31 indexed textboxes.
This is my query:
Code:

sSQL = "SELECT * FROM patient WHERE " & _
          "year(Date_Appointment) = " & cboYear.Text & " and Month(Date_Appointment) = " & cboMonth.ListIndex

This is what I need to do but I couldn't find a way to feed my textboxes as they appear on the picture.

Name:  My pic.jpg
Views: 57
Size:  30.4 KB

As you can see, text1 (2) .text =2 appointments because in my database I have two appointments on 02/12/2017
text1(4) .text = 1 appointment because in my database I have one appointment on 04/12/2017
text1(6) .text = 3 appointments because in my database I have 3 appointment on 06/12/2017
Thanks in advance for any idea
Attached Images
 

VS 2010 The Data from database doesn't retrieve by scanning the rfid tags to the textbox

$
0
0
Hello Once again I'm working for my thesis about RFID attendance system. I just need one more solution to my problem. When i scan my rfid cards to the reader the tag no. is displayed on the textbox in vb.net and change every new cards scanned. The studtags which is a primary key can't retrieve all the values handled but actually it retrieved the data from the database I just need to click backspace while highlighting the textbox I want when scanned the data automatically displayed within it's values no need to click backspace. I will provide some screen capture.

The Capture.jpg without clicking the backspace
The Capture2.jpg with clicking the backspace.

There is no space after the end of the displayed tag number on the textbox. when i click backspace one times there's nothing deleted in the tag , just the values displayed. Thank you I know it's kind of confusing here...
Attached Images
  

VS 2015 [RESOLVED] Closing earlier instances of a dynamic form

$
0
0
I created a function that creates a tooltip like so with a lifetime for how long it shows before it closes.

I have an issue where if I call the createToolTip method while one is still showing, there will be a phantom

Example of the call:
Code:

func.createToolTip("Invalid selection exception", "Cannot parse the selected index in the dictionary list to a valid case.", "Critical", 2000, True)
Code for the createToolTip and the events associated with it:

Code:


Instance variables used in t
    Private WithEvents time As Timer
    Private WithEvents theFrm As Form

    ''' <summary>
    ''' <para>createToolTip()</para>
    ''' Creates a tooltip window and returns the tooltip as type form.
    ''' <para>Strings[title, desc, type], Integer[life], Boolean[showForm]</para>
    ''' Types: 'Info', 'Critical', and 'Exclamation'
    ''' </summary>
    ''' <param name="title"></param>
    ''' <param name="desc"></param>
    ''' <param name="type"></param>
    ''' <param name="life"></param>
    ''' <param name="showForm"></param>
    ''' <returns></returns>

    Public Function createToolTip(ByVal title As String, ByVal desc As String, ByVal type As String, ByVal life As Integer, ByVal showForm As Boolean) As Form
        'Contants of sizes of the X, Y's of the controls used.
        Const frmX As Integer = 200
        Const frmY As Integer = 75
        Const picXY As Integer = 30

        'Controls within the form and a font
        Dim lblTitle As New Label
        Dim txtDesc As New TextBox
        Dim picType As New PictureBox
        Dim pnl1 As New Panel
        Dim pnl2 As New Panel
        Dim fnt As Font

        'Assign variables values
        time.Interval = life
        lblTitle.Text = title
        txtDesc.Text = desc
        fnt = dict.fntTitle.Font

        theFrm = New Form
        theFrm.KeyPreview = True
        theFrm.Icon = My.Forms.frmDictionary.Icon
        theFrm.BackColor = Color.Silver
        theFrm.FormBorderStyle = FormBorderStyle.None
        theFrm.Size = New Size(frmX, frmY)
        theFrm.TopMost = True
        theFrm.Text = "Autogenerated tooltip"

        lblTitle.Font = New Font(fnt.Name, fnt.Size, FontStyle.Bold)
        lblTitle.Dock = DockStyle.Top

        txtDesc.BackColor = Color.Silver
        txtDesc.Multiline = True
        txtDesc.ReadOnly = True
        txtDesc.SelectionStart = 0
        txtDesc.Size = New Size(frmX, frmY - 35)
        txtDesc.Dock = DockStyle.Bottom
        txtDesc.Font = New Font(fnt.Name, 8, FontStyle.Regular)

        pnl1.Size = New Size(frmX - picXY, frmY - picXY - (picXY / 2))
        pnl1.Left += picXY
        pnl2.Size = New Size(frmX, frmY)
        pnl1.Controls.Add(lblTitle)
        pnl2.Controls.Add(txtDesc)

        picType.Size = New Size(picXY, picXY)
        picType.BackgroundImageLayout = ImageLayout.Stretch

        lblTitle.BringToFront()
        picType.BringToFront()

        If type.Equals("Info") Then
            picType.BackgroundImage = My.Resources.stringInfo
            lblTitle.ForeColor = Color.Black
        ElseIf type.Equals("Critical") Then
            picType.BackgroundImage = My.Resources.stringCritical
            lblTitle.ForeColor = Color.DarkRed
        ElseIf type.Equals("Exclamation") Then
            picType.BackgroundImage = My.Resources.stringExclamation
            lblTitle.ForeColor = Color.Black
        End If

        'theFrm.Controls.Add(lblTitle)
        'theFrm.Controls.Add(txtDesc)
        theFrm.Controls.Add(picType)
        theFrm.Controls.Add(pnl1)
        theFrm.Controls.Add(pnl2)

        'Tag each control to be used by the click event
        For Each c As Control In theFrm.Controls
            AddHandler c.MouseClick, AddressOf theFrm_ClickHandler
        Next

        If showForm Then
            theFrm.Show()
        End If

        theFrm.Location = New Point(Cursor.Position.X + 10, Cursor.Position.Y - 35)
        time.Start()
        time.Enabled = True

        Return theFrm
    End Function

    ''' <summary>
    ''' Timer_Tick
    ''' <para>Handles the global varibles time tick method. Used for createToolTip</para>
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>

    Private Sub Timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles time.Tick
        time.Stop()
        theFrm.Close()
    End Sub

    ''' <summary>
    ''' theFrm_ClickHandler
    ''' <para> Handles click events for theFrm</para>
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>

    Private Sub theFrm_ClickHandler(sender As Object, e As MouseEventArgs) Handles theFrm.MouseClick
        If e.Button = MouseButtons.Left Or e.X > 0 Or e.Y > 0 Then
            theFrm.Close()
        End If
    End Sub

So for example, I run the createToolTip method twice without the first one closing.
The last created tooltip will behave correctly but the one before it will not follow correctly. I presume this has to do with me stopping the timer
function.

I want this events to work independently. If I have 10 tooltips running, I want them all to last each of their specified lifetime and be handled independently with the clickHandler

Keep focus on parent when interacting with child (and vice versa)?

$
0
0
Hi all,

I'm trying to maintain focus on the parent and the child at the same time when interacting (clicking) on either one. Just to clarify, this is not a multi-document interface, and uses this code:

Code:

Dim ChildProc As Process = Process.GetProcessesByName("MyChildApp").FirstOrDefault

        If ChildProc IsNot Nothing Then

            SetParent(ChildProc.MainWindowHandle, ChildContainerPanel.Handle)
            SendMessage(ChildProc.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)

        End If

So, obviously, when I click on the child form, which is embedded in on my main form, it shifts focus to the child form (and vice versa). This causes all sorts of complications for my application. How can I ensure that if I click on my child form, my form is in focus and if I click on my form, my client form remains in focus?

What I've tried before asking this question:

I've tried experimenting with ZOrder if my MainForm_LostFocus, however, it has no effect.

Thanks for the help.
[EDIT] - Off topic, but is it normal for me to be placing so much white-space is my code, I do it to make certain related components more in focus to increase readability, however will this effect my application's performance at all?

Having a message coming up when I start vb6.0

$
0
0
Hello, I'm getting this message every time I open vb6.0. Dose anyone know how I can get rid of this because I cant load vb, it just closes. Thanks





Name:  error.jpg
Views: 102
Size:  18.6 KB
Attached Images
 

VS 2017 Change height with mouse

$
0
0
Hi guys,

I am new to visual basic 2017. I have managed to programmatically draw a vertical rectangle / line:

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim myPen As Pen
myPen = New Pen(Drawing.Color.Blue, 5)

Dim myGraphics As Graphics = Me.CreateGraphics

myGraphics.DrawRectangle(myPen, 100, 100, 1, 50)
End Sub
End Class

---------------

Is it possible to change its height by a user with the help of the mouse during runtime?

Thanks!!!!

Anyone know how to analyze 5 temp files produced by vb6.exe while compiling???

$
0
0
when press compile button in vb6.exe
we can see 5 temp files for each module, normal module as well as class module.

VB######DB 'DataBase binding
VB######EX 'if module EXposed
VB######GL 'module GLobal attribute
VB######IN 'module INstancing attribute
VB######SY 'unknown now

it seems that, vb6.exe compile each module to these temp files
and then transfer these 5 temp file to c2.exe to make an obj file.

and vb5 is also like that

we guess that c2.exe can not read some of the vb6 features, so it need VB6IDE to translate once...

can anyone that are familiar with PE can help analyze those temp files, so that we will try to abandon vb6.exe.

Foreign key not working correctly (throws constraint exception)

$
0
0
I have two tables one is a book table and the other is a reservation table. i have set the book ID from the book table as a fk in the reserver table but i keep getting this error

"System.Data.InvalidConstraintException was unhandled
Message: An unhandled exception of type 'System.Data.InvalidConstraintException' occurred in System.Data.dll
Additional information: ForeignKeyConstraint FK_BookTable_ReservationTable requires the child key values (0) to exist in the parent table."

i have added a book to my book table with the id 0 and it save successfully but when i try to add a reserver to the reservation table with the book id 0 i get this exception. i am not sure why it throwing this exception when i have a Book ID 0 in the parent table. can anyone help me please.

Here is the code for the relation table
vb Code:
  1. Imports System.Data.Sql
  2. Imports System.Data.SqlClient
  3. Public Class Reservation_Table
  4.     Private Shared instance As Reservation_Table
  5.     Public Shared ReadOnly Property ReservationTableInstance() As Reservation_Table
  6.         Get
  7.             If instance Is Nothing Then
  8.                 instance = New Reservation_Table
  9.             End If
  10.             Return instance
  11.         End Get
  12.     End Property
  13.     Private Sub ReservationTableBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs)
  14.         Me.Validate()
  15.         Me.ReservationTableBindingSource.EndEdit()
  16.         Me.TableAdapterManager.UpdateAll(Me.Librarymanagementdatabase2DataSet)
  17.  
  18.     End Sub
  19.  
  20.     Private Sub Reservation_Table_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  21.         'TODO: This line of code loads data into the 'Librarymanagementdatabase2DataSet.ReservationTable' table. You can move, or remove it, as needed.
  22.         Me.ReservationTableTableAdapter.Fill(Me.Librarymanagementdatabase2DataSet.ReservationTable)
  23.         'TODO: This line of code loads data into the 'Librarymanagementdatabase2DataSet.ReservationTable' table. You can move, or remove it, as needed.
  24.         Me.ReservationTableTableAdapter.Fill(Me.Librarymanagementdatabase2DataSet.ReservationTable)
  25.  
  26.     End Sub
  27.  
  28.     Private Sub ReservationTableDataGridView_CellContentClick(sender As Object, e As DataGridViewCellEventArgs)
  29.  
  30.     End Sub
  31.  
  32.     Private Sub ReservationTableBindingNavigatorSaveItem_Click_1(sender As Object, e As EventArgs) Handles ReservationTableBindingNavigatorSaveItem.Click
  33.         Me.Validate()
  34.         Me.ReservationTableBindingSource.EndEdit()
  35.         Me.TableAdapterManager.UpdateAll(Me.Librarymanagementdatabase2DataSet)
  36.  
  37.     End Sub
  38.  
  39.     Private Sub AddButton_Click(sender As Object, e As EventArgs) Handles AddButton.Click
  40.         databaseconnection.cn.Open()
  41.         databaseconnection.cm.Connection = databaseconnection.cn
  42.         Try
  43.             ReservationTableBindingSource.AddNew()
  44.             Reserver_NameTextBox.Select()
  45.             databaseconnection.cm.CommandText = "INSERT INTO [dbo].[ReservationTable] ([Reserver Name], [Book ID], [Book Name], [Check out Date], [Check In Date]) VALUES ('" & Reserver_NameTextBox.Text & "', '" & Book_IDTextBox.Text & "', '" & Book_NameTextBox.Text & "', '" & Check_out_dateDateTimePicker.Value.Date & "', '" & Check_in_dateDateTimePicker.Value.Date & "')"
  46.             databaseconnection.cm.ExecuteNonQuery()
  47.             databaseconnection.cn.Close()
  48.         Catch ex As Exception
  49.             MessageBox.Show(ex.Message)
  50.         End Try
  51.     End Sub
  52.  
  53.     Private Sub SaveButton_Click(sender As Object, e As EventArgs) Handles SaveButton.Click
  54.         ReservationTableBindingNavigatorSaveItem.PerformClick()
  55.         Try
  56.             Me.Validate()
  57.             Me.ReservationTableBindingSource.EndEdit()
  58.             Me.TableAdapterManager.UpdateAll(Me.Librarymanagementdatabase2DataSet)
  59.             ReservationTableBindingSource.AddNew()
  60.             Reserver_NameTextBox.Select()
  61.         Catch ex As Exception
  62.  
  63.         End Try
  64.     End Sub
  65. End Class

here is the relation source code for the reservation table
vb Code:
  1. CREATE TABLE [dbo].[ReservationTable] (
  2.     [Reserver ID]    INT          IDENTITY (1, 1) NOT NULL,
  3.     [Reserver Name]  VARCHAR (50) NULL,
  4.     [Book ID]        INT          NOT NULL,
  5.     [Book Name]      VARCHAR (50) NULL,
  6.     [Check out date] DATE         NULL,
  7.     [Check in date]  DATE         NULL,
  8.     PRIMARY KEY CLUSTERED ([Reserver ID] ASC),
  9.     CONSTRAINT [FK_ReservationTable_ToTable] FOREIGN KEY ([Book ID]) REFERENCES [dbo].[BookTable] ([Book ID])
  10. );


here the code for the book table

vb Code:
  1. Imports System.Data.SqlClient
  2. Imports System.Data.Sql
  3. Public Class BookTable
  4.     Private Shared instance As BookTable
  5.     Public Shared ReadOnly Property BookTableInstance() As BookTable
  6.         Get
  7.             If instance Is Nothing Then
  8.                 instance = New BookTable
  9.             End If
  10.             Return instance
  11.         End Get
  12.     End Property
  13.     'Dim cn As New SqlConnection("Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename='c:\users\eugen\documents\visual studio 2015\Projects\Library management 11\Library management 11\Librarymanagementdatabase2.mdf';Integrated Security=True")
  14.     'Dim cm As SqlCommand
  15.     Private Sub BookTableBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs)
  16.         Me.Validate()
  17.         Me.BookTableBindingSource.EndEdit()
  18.         Me.TableAdapterManager.UpdateAll(Me.Librarymanagementdatabase2DataSet)
  19.  
  20.     End Sub
  21.  
  22.     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  23.         'TODO: This line of code loads data into the 'Librarymanagementdatabase2DataSet.BookTable' table. You can move, or remove it, as needed.
  24.         Me.BookTableTableAdapter.Fill(Me.Librarymanagementdatabase2DataSet.BookTable)
  25.         'TODO: This line of code loads data into the 'Librarymanagementdatabase2DataSet.BookTable' table. You can move, or remove it, as needed.
  26.         Me.BookTableTableAdapter.Fill(Me.Librarymanagementdatabase2DataSet.BookTable)
  27.  
  28.     End Sub
  29.  
  30.     Private Sub SaveButton_Click(sender As Object, e As EventArgs) Handles SaveButton.Click
  31.         BookTableBindingNavigatorSaveItem.PerformClick()
  32.         If Book_NameTextBox.Text = Nothing Then
  33.             Book_NameTextBox.Text = "unknown"
  34.         End If
  35.         If AuthorTextBox.Text = Nothing Then
  36.             AuthorTextBox.Text = "unknown"
  37.         End If
  38.         If ISBNTextBox.Text = Nothing Then
  39.             ISBNTextBox.Text = "unknow"
  40.         End If
  41.         If Book_ConditionTextBox.Text = Nothing Then
  42.             Book_ConditionTextBox.Text = "Unknown"
  43.         End If
  44.         If GenreTextBox.Text = Nothing Then
  45.             GenreTextBox.Text = "Uknown"
  46.         End If
  47.         Try
  48.             Me.Validate()
  49.             Me.BookTableBindingSource.EndEdit()
  50.             Me.TableAdapterManager.UpdateAll(Me.Librarymanagementdatabase2DataSet)
  51.             BookTableBindingSource.AddNew()
  52.             Book_NameTextBox.Select()
  53.         Catch ex As Exception
  54.  
  55.         End Try
  56.     End Sub
  57.  
  58.     Private Sub AddButton_Click(sender As Object, e As EventArgs) Handles AddButton.Click
  59.         databaseconnection.cn.Open()
  60.         databaseconnection.cm.Connection = databaseconnection.cn
  61.         Try
  62.             BookTableBindingSource.AddNew()
  63.             Book_NameTextBox.Select()
  64.             databaseconnection.cm.CommandText = "INSERT INTO [dbo].[BookTable] ([Book Name], [Author], [ISBN], [Book Condition], [Genre] [Copies]) VALUES ('" & Book_NameTextBox.Text & "', '" & AuthorTextBox.Text & "', '" & ISBNTextBox.Text & "', '" & Book_ConditionTextBox.Text & "', '" & GenreTextBox.Text & "' , '" & CopiesTextBox.Text & "' ,)"
  65.             databaseconnection.cm.ExecuteNonQuery()
  66.             databaseconnection.cn.Close()
  67.         Catch ex As Exception
  68.  
  69.         End Try
  70.     End Sub
  71.  
  72.     Private Sub BookTableBindingNavigatorSaveItem_Click_1(sender As Object, e As EventArgs) Handles BookTableBindingNavigatorSaveItem.Click
  73.         Me.Validate()
  74.         Me.BookTableBindingSource.EndEdit()
  75.         Me.TableAdapterManager.UpdateAll(Me.Librarymanagementdatabase2DataSet)
  76.  
  77.     End Sub
  78. End Class

the relation source code for the Book table
vb Code:
  1. CREATE TABLE [dbo].[BookTable] (
  2.     [Book ID]        INT          IDENTITY (-1, -1) NOT NULL,
  3.     [Book Name]      VARCHAR (50) NULL,
  4.     [Author]         VARCHAR (50) NULL,
  5.     [ISBN]           INT          NULL,
  6.     [Book Condition] VARCHAR (50) NULL,
  7.     [Genre]          VARCHAR (50) NULL,
  8.     [Copies]         INT          NULL,
  9.     PRIMARY KEY CLUSTERED ([Book ID] ASC)
  10. );
Attached Images
   

Cut sting value under condition

$
0
0
I have two string values.

s1 = "This is my test value #2213 and its great"
s2 = "This #ASD is my #Test value and number is #2215"

The point is to pick up 4 digit number behind the # mark.

With

Code:

_lItems.Add(item.Title.Substring(item.Title.IndexOf("#") + 1, 4))
I can cut the string but but that is not correct. I need to scrap only 4 digit number behind # mark.

How to make it

[RESOLVED] Information not saving to Database

$
0
0
Hi, I am a student and i am trying to create a Library Management system for my project. I have created a local database in visual studio 2015 to save information from the tables i have created. the database is (my sql server database file..MDF). I have created a connection string and a command string to save and execute queries on my database. I am having a trouble saving information to my customer Table. i have managed to get the information to save into my Booktable but can't get it to save in my customer table. For some odd reason the auto increment won't work for the user ID and i get a error stating the customer table does not accept null values for the column User ID. The user ID is a primary key and should not accept null values but the auto incrementer should generate a new number when adding a new record/row but it does not work.

So can you help me save the information into my customer table and help me solve the problem of getting my auto incrementer to work for the USER ID column.

Here is the code for my customer table
vb.net code:
Code:

Imports System.Data.Sql
Imports System.Data.SqlClient
Public Class CustomerTable
    Dim cn As New SqlConnection("Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename='C:\Users\Eugen\Downloads\Library management System (lastestone)\Library management System (1)\Library management System\Library management System\Database1.mdf';Integrated Security=True")
    Dim cm As New SqlCommand
    Private Sub CustomerTableBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles CustomerTableBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.CustomerTableBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.BookTableSQL)

    End Sub

    Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'BookTableSQL.CustomerTable' table. You can move, or remove it, as needed.
        Me.CustomerTableTableAdapter.Fill(Me.BookTableSQL.CustomerTable)

    End Sub

    Private Sub AddButton_Click(sender As Object, e As EventArgs) Handles AddButton.Click
        cn.Open()
        cm.Connection = cn
        Me.Validate()
        Me.CustomerTableBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.BookTableSQL)
        Try
            CustomerTableBindingSource.AddNew()
            User_NameTextBox.Select()
            cm.CommandText = " insert into [dbo].[CustomerTable] INSERT INTO [dbo].[CustomerTable] ([Book ID], [User Name], [Check in date], [Chexk out date], [Copies], [Transactions]) VALUES ( '" & Book_IDTextBox.Text & "' , '" & User_NameTextBox.Text & "' , '" & Check_in_dateDateTimePicker.Value.Date & "' , '" & Chexk_out_dateDateTimePicker.Value.Date & "', '" & CopiesTextBox.Text & "', '" & TransactionsTextBox.Text & "'  )"
            cm.ExecuteNonQuery()
            cn.Close()
        Catch ex As Exception
            MessageBox.Show(ex.Message)

        End Try
    End Sub

couldn't find the tags for VB can you post it for me please
Attached Images
  

[RESOLVED] Cut sting value under condition

$
0
0
I have two string values.

s1 = "This is my test value #2213 and its great"
s2 = "This #ASD is my #Test value and number is #2215"

The point is to pick up 4 digit number behind the # mark.

With

Code:

_lItems.Add(item.Title.Substring(item.Title.IndexOf("#") + 1, 4))
I can cut the string but but that is not correct. I need to scrap only 4 digit number behind # mark.

How to make it

which Installer VB to win 7,8 10

having a problem in my code

$
0
0
so the focus of this program is to take a number only take the last 4 digits ad 1 to it and give it back
but for some reason the case part at the bottom where he decides how many zeros have to be added never workes he always picks the else case

Dim nummer1 As String
nummer1 = txtNummer.Text
nummer1 = nummer1.Substring(3)
nummer1 = Getalvermeerderen(nummer1)

Select Case nummer1
'.tostring erbij omdat we in de module integers gebruikt werden
Case 0 To 99
txtNummer.Text = "16/00" & nummer1.ToString
Case 100 To 999
txtNummer.Text = "16/0" & nummer1.ToString
Case Else
txtNummer.Text = "16/" & nummer1.ToString

End Select
End Sub
End Class
this is the code fot the module i use do +1
Public Function Getalvermeerderen(ByVal Getal As Integer) As Integer
Dim resultaat As Integer
esultaat = Getal + 1

Return resultaat
End Function
thanks in advance guys

VS 2010 Inserting all data from the datagridview to mysql database help

$
0
0
Hello I'm getting an error in the cmd.ExecuteNonQuery() part I just want to save all the displayed or data content from the Datagridview to my Database.

There is no problem about filling the datagridview with some data. I have filled it already the only question is how can I save and solve my error ,I also get an error row 1 did not match or something like that .I input the database values from my database sql but I failed. Did anything I inputted wrong in the code.?

Code:

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

    For Each row As DataGridViewRow In DataGridView1.Rows
        Dim constring As String = "server=localhost;userid=root;password=1234;database=dat"
        Using con As New MySqlConnection(constring)
            Using cmd As New MySqlCommand("INSERT INTO studlogs VALUES(@studtags, @idno, @lastxt, @firstxt, @middletxt, @dob, @log, @age, @timein, @crse)", con)
                cmd.Parameters.AddWithValue("@studtags", row.Cells("StudentTag").Value)
                cmd.Parameters.AddWithValue("@idno", row.Cells("StudentID").Value)
                cmd.Parameters.AddWithValue("@lastxt", row.Cells("LastName").Value)
                cmd.Parameters.AddWithValue("@firstxt", row.Cells("FirstName").Value)
                cmd.Parameters.AddWithValue("@middletxt", row.Cells("MiddleName").Value)
                cmd.Parameters.AddWithValue("@dob", row.Cells("Age").Value)
                cmd.Parameters.AddWithValue("@log", row.Cells("Status").Value)
                cmd.Parameters.AddWithValue("@age", row.Cells("Birthday").Value)
                cmd.Parameters.AddWithValue("@timein", row.Cells("Timein").Value)
                cmd.Parameters.AddWithValue("@crse", row.Cells("CourseSec").Value)


                con.Open()
                cmd.ExecuteNonQuery()
                con.Close()
            End Using
        End Using
    Next
    MessageBox.Show("Records inserted.")

End Sub


Private Sub Students_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    Try
        DataGridView1.AllowUserToAddRows = False ' Disabled or hide (*) Symbol...

        DataGridView1.RowHeadersVisible = False 'To hide Left indicator..
        DataGridView1.DefaultCellStyle.SelectionBackColor = Color.SteelBlue  'Selection backcolor....
        DataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGoldenrodYellow 'Alternating Backcolor.
        DataGridView1.AllowUserToResizeRows = False 'Disabled  row resize...
        DataGridView1.ReadOnly = True
        DataGridView1.MultiSelect = False
        DataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect
        DataGridView1.ShowRowErrors = False
        DataGridView1.ShowCellErrors = False

        table2.Columns.Add("StudentTag", Type.GetType("System.String"))
        table2.Columns.Add("StudentID", Type.GetType("System.Int32"))
        table2.Columns.Add("LastName", Type.GetType("System.String"))
        table2.Columns.Add("FirstName", Type.GetType("System.String"))
        table2.Columns.Add("MiddleName", Type.GetType("System.String"))
        table2.Columns.Add("Age", Type.GetType("System.Int32"))
        table2.Columns.Add("Status", Type.GetType("System.String"))
        table2.Columns.Add("Birthday", Type.GetType("System.String"))
        table2.Columns.Add("Timein", Type.GetType("System.String"))
        table2.Columns.Add("CourseSec", Type.GetType("System.String"))

        If table2.Rows.Count > 0 Then
            logins.Text = table2.Rows.Count.ToString()
        End If
        DataGridView1.DataSource = table2
    Catch ex As Exception

    End Try

Lost My Undo - Re do Typing Shortcut In GUI

$
0
0
I seem to have lost my Undo & Redo typing shortcut for the code editor window. It still exists under the Edit drop-down but I miss the shortcut. I've tried to restore it with the right click "Customize" option to no avail. :confused:

Thanks,
Chris

DataGridView column resizing takes to long

$
0
0
Hi

i've got a sub here which basically just resizes the columns on a datagridview to show the contents but its taking over 20 seconds to do this on just 10-15 columns, the tables are quite large sometimes which maybe the cause. Is there anything i can do to optimize this code, i cant think of anything.

Code:

Public Sub posted_FormatTable(Optional ControlOnlyResizeFlag As Boolean = False)
        Dim ClW As Int32
        With dgvPosted
            For Each Cl As DataGridViewColumn In .Columns
                If ControlOnlyResizeFlag Then
                    Select Case Cl.Index
                        Case 0 To 3
                            'set to autofit cells then disable to allow resizing
                            Cl.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
                            ClW = Cl.Width
                            Cl.AutoSizeMode = DataGridViewAutoSizeColumnMode.None
                            Cl.Width = ClW + 10
                            'prevent column sorting
                            Cl.SortMode = DataGridViewColumnSortMode.NotSortable
                    End Select
                Else
                    'set to autofit cells then disable to allow resizing
                    Cl.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
                    ClW = Cl.Width
                    Cl.AutoSizeMode = DataGridViewAutoSizeColumnMode.None
                    Cl.Width = ClW + 10
                    'prevent column sorting
                    Cl.SortMode = DataGridViewColumnSortMode.NotSortable
                End If


            Next

            .Columns(0).Frozen = True
            .Columns(0).Width = 19

        End With

        AlignComboToGridCell(dgvPosted, cmb_TRX_Containers, 4)
        AlignComboToGridCell(dgvPosted, cmb_TRX_PostedSymbols, 5)
        AlignComboToGridCell(dgvPosted, cmb_TRX_FeedYards, 2)

    End Sub

Start process on remote Pc via Wmi problem

$
0
0
I have a problem when i try to start batch not locate on system32 folder

If i copy oro.cmd on C:\temp and try to start oro.mcd and call function with RemoteStart(remoteServer, {"c:\temp\oro.cmd"}) doesn't works

My question is cmd must be on windows folder??

this is my code:

RemoteStart(remoteServer, {"oro.cmd"})

Function RemoteStart(ByVal Server As String, ByVal sProcess As Object)
Try
Dim connOptions As ConnectionOptions = New ConnectionOptions()
connOptions.Username = "sms"
connOptions.Password = "Mc"
connOptions.EnablePrivileges = True
Dim theScope As ManagementScope = New ManagementScope("\\" & Server & "\root\cimv2", connOptions)
Dim theClass As New ManagementClass(theScope, New ManagementPath("Win32_Process"), New ObjectGetOptions())
theClass.InvokeMethod("Create", sProcess)
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try

Return Nothing

End Function

Could you help me?

do we have discord server chats?

VS 2017 Handles clause requires a WithEvents variable - error

$
0
0
Hello

I am getting a red underline in this line of code in my VS 2017 aspx.vb contact form:

Name:  contact_submitted.jpg
Views: 16
Size:  6.0 KB

In my contact aspx form, I have

Code:

<button type="submit" class="contact_submitted">Send Now</button>
The error I am getting is that 'a Handles clause requires a WithEvents variable' - I am not too sure what that means.

Thanks for any help.

Steve
Attached Images
 

[RESOLVED] Click an empty TableLayoutPanel cell get the cell ID

$
0
0
Hi,

I can find loads of methods for finding the ID of a TableLayoutPanel cell with an object in that cell, and loads of methods for finding the ID of all the empty cells, what I'm trying to find is the ID of a specific empty cell from a mouse click.

Code:

    Private Sub TableLayoutPanel1_MouseDown(sender As Object, e As MouseEventArgs) Handles TableLayoutPanel1.MouseDown

        Dim pt As Point = Cursor.Position
        Dim pt1, pt2 As Int32
        pt1 = TableLayoutPanel1.GetCellPosition(TableLayoutPanel1).Row
        pt2 = TableLayoutPanel1.GetCellPosition(TableLayoutPanel1).Column
    End Sub

I thought this code should do the trick, and intellisense has no objections...
sadly though this just returns -1 for both pt1 and pt2.

I thought I might get some results from the cursor, I do get a point from the cursor position but can't find how to use the result. As the point returned from the cursor depends on where the form is on the screen, it's not going to help much anyway.

(Using 'MouseClick' in place of 'MouseDown' does give exactly the same result.)



Poppa.
Viewing all 42124 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>