You are on page 1of 4

Check Box

Check boxes are used when more than one option may need to be checked.

function pushbutton1_Callback(hObject, eventdata, handles)


if get(handles.cb1,'value') ==1

msgbox( [ 'Hello ' get(handles.cb1,'string' ) ] );


end

if get(handles.cb2,'value') ==1

msgbox( [ 'Hello ' get(handles.cb2,'string' ) ] );


end
POPUP MENUE
the pop-up contains a menu of commands and stays on the screen, screen appears with
a list of menu items from which to select.

function p1_Callback(hObject, eventdata, handles)


%hObject handle to p1 (see GCBO)
%Hints: contents = cellstr(get(hObject,'String')) returns
p1 contents as cell array
%contents{get(hObject,'Value')}return selected item from p1
c = cellstr(get(hObject,'String'));
switch get(hObject,'value')
case 1
msgbox ([c(1) '=1']);
case 2
msgbox ([c(2) '=2']);
case 3
msgbox ([c(3) '=3']);
end
LIST BOX
List box allows the user to select one item from a list contained within a static, multiple
line text box. The user clicks inside the box on an item to select it.

function listbox1_Callback(hObject, eventdata, handles)


% hObject handle to listbox1
% contents = cellstr(get(hObject,'String')) returns
listbox1 contents as cell array
% get(hObject,'Value')returns selected item from listbox1
c = cellstr(get(hObject,'String'));
switch get(hObject,'Value')
case 1
msgbox([ 'hello ' c(1)]);
case 2
msgbox([ 'hello ' c(2)]);
case 3
msgbox([ 'hello ' c(3)]);
end
Q1: Design GUI to select width from list box and select length from 2nd list box then
show the volume.

Q2: Design GUI to select Number from 2:10 from list box then show its factorial.

You might also like