The entire script needs to be within the combo box's function. Also, you have choices 1 and 2, but are comparing against a value of 3 or 4. Try this:
New Window( "test",
<<modal,
x = Combo Box( {"1", "2"},
<<set function( Function( {this},
value = this << get;
If(
value == 1,
Try( (this << sib) << deletebox ); // delete what might already exist
this << sibappend( H List Box( y = Number Edit Box( . ) ) );, // add new box
value == 2,
Try( (this << sib) << deletebox ); // delete what might already exist
this << sibappend( // add new box
H List Box(
y = Number Edit Box( . ),
y2 = Number Edit Box( . )
)
);
);
) )
),
H List Box( y = Number Edit Box( . ) ) // since 1 is selected by default, put the box here initially
);