Forum Discussion

mazhar555's avatar
mazhar555
Contributor
14 years ago

How to insert NULL Value??

HI,



I am checking Mandatory information whether its messing or not, so from Excel i want to input NULL value in my Text Field, while execution it prompts for Type Mismatch as it expecting a text value...so is there any way that i can insert NULL value from excel into a text field.



Thanks and Regards




4 Replies

  • Hi Muhammad,


    As I understand, you need to assign a null value to a text box control in your application. If so, the approach you need to use depends solely on the control. If it is possible to enter the null value via some keys combination (e.g. Ctrl + Delete), you can use the Keys method to simulate the keystroke. Also, you can try compiling the tested application with debug information and setting the internal Text property (or any other property which stores the control's text) to null directly from TestComplete.

  • naplespoet's avatar
    naplespoet
    New Contributor
    Just a quick follow up to this,  its kind of in the same area i'm having an issue,

    Im new to testcomplet and I have a CSV file where it is in a loop and in different rows, different fields are empty.



    so far as 



    1. first name, last name, middle name, address  -- all are populated the first time

    2. first name, last name, middle name, address  -- first is blank value

    3. first name, last name, middle name, address  -- last is blank value

    4. first name, last name, middle name, address  -- address is a blank value.



    and in the loop it runs through each row and I'm trying to get it to insert the null value into the field and save the new entry.



    I keep getting type mismatch and cannot figure out how to get around it or to have the loop remove the values on each one.  I just need to see if its possible to do it without having to have the script on each iteration delete that field entry after.



    is this possible?
  • Hi,



    After you obtain a value from your file and before using it, check whether it is empty. Use the aqObject.GetVarType method to do this (see the "aqObject.GetVarType" help topic).
  • Hi, i think we cannot insert Null directly from excel, have to do some coding part, so i have tried the following code which is working:



    Sub addStudentInformation(firstName, lastName)

    'Assuming that values are coming from excel file



    If firstName = "" Then

        application.firstName.value = ""  'Inserting Null value to FirstName

    Else

        application.firstName.value = Excel.Value(0) 'ExcelColumn

    End If



    or



    If Not firstName = "" Then

        application.firstName.value = Excel.Value(0) 'ExcelColumn

    End If



    in that case TC will left the first name as it is and move to the next field.



    You may have to do this for all fields.