none
The conversion of the string "En Cours" to type integer is not valid!! RRS feed

  • Question

  • Hi ,

    I get this Error "The conversion of the string "En Cours" to type integer is not valid."

    When I run this code.

    Private Sub Dgw_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles Dgw.CellContentClick Try If Dgw.SelectedRows.Count = 0 Then Exit Sub End If Dim dr As Integer = Dgw.CurrentCell.RowIndex + 0 If dr > -1 Then Cage = CInt(Dgw.Rows(dr).Cells(2).Value) Race = CStr(Dgw.Rows(dr).Cells(3).Value) DateDeCouvaison = CDate(Dgw.Rows(dr).Cells(8).Value) DateMirageŒufs = CDate(Dgw.Rows(dr).Cells(9).Value) DatedEclosion = CDate(Dgw.Rows(dr).Cells(10).Value) ŒufsCouvés = CInt(Dgw.Rows(dr).Cells(13).Value) If IsDBNull(Dgw.Rows(dr).Cells(14).Value) = True Then ŒufsFécondés = "En Cours" Else ŒufsFécondés = CInt(Dgw.Rows(dr).Cells(14).Value) End If If IsDBNull(Dgw.Rows(dr).Cells(16).Value) = True Then ŒufsEclos = "En Cours" Else ŒufsEclos = CInt(Dgw.Rows(dr).Cells(16).Value) End If If IsDBNull(Dgw.Rows(dr).Cells(21).Value) = True Then NetSevrés = "En Cours" Else NetSevrés = CInt(Dgw.Rows(dr).Cells(21).Value) End If If IsDBNull(Dgw.Rows(dr).Cells("Photo").Value) = True Then frmInfo.PictureInfo.Image = My.Resources.UnUsed Else Dim data As Byte() = Dgw.Rows(dr).Cells("Photo").Value Using ms As New MemoryStream(data) frmInfo.PictureInfo.Image = Image.FromStream(ms) End Using End If frmInfo.ShowDialog() End If Catch ex As Exception MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub


    The Code Of frmInfo Is :

    Private Sub frmInfo_Load(sender As Object, e As EventArgs) Handles MyBase.Load txtCage.Text = Cage.ToString txtRace.Text = Race.ToString txtDateCouvaison.Text = DateDeCouvaison.ToLongDateString() txtDateMirage.Text = DateMirageŒufs.ToLongDateString() txtEclosion.Text = DatedEclosion.ToLongDateString() txtCouvés.Text = ŒufsCouvés.ToString txtFecondés.Text = ŒufsFécondés.ToString() txtEclos.Text = ŒufsEclos.ToString() txtNetSevrés.Text = NetSevrés.ToString() PictureInfo.Image = PictureInfo.Image End Sub

    So thank you very Much For your Help.

    Best Regards .


    • Edited by Bajtitou Thursday, May 9, 2019 9:14 AM
    Thursday, May 9, 2019 9:10 AM

Answers

  • Hi,

    ŒufsEclos is an integer type?"En Cours" cannot be converted to integer type.You can try to define ŒufsEclos as a string type.

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Bajtitou Thursday, May 9, 2019 11:58 AM
    Thursday, May 9, 2019 9:23 AM

All replies

  • Hi,

    ŒufsEclos is an integer type?"En Cours" cannot be converted to integer type.You can try to define ŒufsEclos as a string type.

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Bajtitou Thursday, May 9, 2019 11:58 AM
    Thursday, May 9, 2019 9:23 AM
  • Hello,

    The first thing to do in this case is have Option Strict On in the form which would clear things up if ŒufsEclos  is not declared as an Object but instead declared as a numeric type than when attempting to set ŒufsEclos to a string where it should be a numeric would be clear as the code would not compile.

    Of course if there are other issues similar to this they will cause the code not to compile also. 99 percent of the time code should be compiled with Option Strict On.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Thursday, May 9, 2019 10:51 AM
    Moderator
  • Hi,

    ŒufsEclos is an integer type?"En Cours" cannot be converted to integer type.You can try to define ŒufsEclos as a string type.

    Best Regards,

    Alex


    Hi , 

    Yes ŒufsEclos is an integer type.

        Public ŒufsCouvés As Integer
        Public ŒufsFécondés As Integer
        Public ŒufsEclos As integer
        Public NetSevrés As Integer

    changing to :

        Public ŒufsCouvés As String
        Public ŒufsFécondés As String
        Public ŒufsEclos As String
        Public NetSevrés As String

    Now It work fine.

    So thank you very Much .

    Best Regards.

    • Marked as answer by Bajtitou Thursday, May 9, 2019 11:58 AM
    • Unmarked as answer by Bajtitou Thursday, May 9, 2019 11:58 AM
    Thursday, May 9, 2019 11:58 AM
  • Hello,

    The first thing to do in this case is have Option Strict On in the form which would clear things up if ŒufsEclos  is not declared as an Object but instead declared as a numeric type than when attempting to set ŒufsEclos to a string where it should be a numeric would be clear as the code would not compile.

    Of course if there are other issues similar to this they will cause the code not to compile also. 99 percent of the time code should be compiled with Option Strict On.


    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Hi, 

    Thank you Karen for Very Much for your Help.

    Best Regards.

    Thursday, May 9, 2019 11:59 AM