cancel
Showing results for 
Search instead for 
Did you mean: 

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

former_member183402
Participant
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

former_member185682
Active Contributor
0 Kudos

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

former_member183402
Participant
0 Kudos

Thank you so much Diego.

Answers (0)