Skip to Content

How to assign textbox value to variable in VB without error of Illegal value entered in SAP B1 9.2?.

Hi all,

I have a problem in SDK codes,

I opened project in C:\Program Files\SAP\SAP Business One SDK\Samples\UDO\addUDO\VB.NET then I added new textbox3 in order to understand well how SDK codes work.

If I use use TextBox3.Text I can add data to database as shown bellow

        Try
            oCompanyService = oCompany.GetCompanyService
            'Get GeneralService (oCmpSrv is the CompanyService)
            oGeneralService = oCompanyService.GetGeneralService("SM_MOR")
            'Create data for new row in main UDO
            oGeneralData = oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData)
            oGeneralData.SetProperty("U_Price", TextBox3.Text)

But if I declare variable and assign value of TextBox3 to that the variable I cannot add data to the database, the following error message is displayed Illegal value entered

        Dim TestNumber1 As Integer
        Try
            TestNumber1 = Val(TextBox3.Text)
            oCompanyService = oCompany.GetCompanyService
            'Get GeneralService (oCmpSrv is the CompanyService)
            oGeneralService = oCompanyService.GetGeneralService("SM_MOR")
            'Create data for new row in main UDO
            oGeneralData = oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData)
            oGeneralData.SetProperty("U_Price", TestNumber1)

Please anyone can help me.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Dec 13, 2016 at 03:37 PM

    Hi Rurangwa,

    This happened because in the sample, the field U_Price on the database is a alpha field and your variable is an integer. Change the type of your variable to string.

    Kind Regards,

    Diego Lother

    Add comment
    10|10000 characters needed characters exceeded