Skip to Content
0

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

Dec 13, 2016 at 03:15 PM

95

avatar image

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.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
DIEGO LOTHER Dec 13, 2016 at 03:37 PM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thank you so much Diego.

0