How to set BackgroundColor on edit text using mycode and fix 1 error?

1 visualización (últimos 30 días)
function [] = main ()
figure('name','CROSSWORD PUZZLE','MenuBar','none','Color',[.7,.78,1],'units','normalized','outerposition',[0 0 .5 .8]')
Title='CROSSWORD';
a=1;
for x=20:30:260
tagn=strcat('TBox',num2str(a));
uicontrol('Style','edit','position',[x, 530, 30, 30],'String',Title(a),'FontSize',20,'Tag',tagn)
a=a+1;
end
TitleB='PUZZLE';
a=1;
for x=80:30:230
tagn=strcat('TBox1',num2str(a));
uicontrol('Style','edit','position',[x, 500, 30, 30],'String',TitleB(a),'FontSize',20,'Tag',tagn)
a=a+1;
end
S.pb = uicontrol('Style','pushbutton','Position',[500 350 60 30],'String','PLAY');
set(S.pb,'callback',@game)
S.ob = uicontrol('Style','pushbutton','Position',[500 300 60 30],'String','OPTION');
set(S.ob,'callback',@set)
function [] = game(hObject, eventdata, handles)
set(hObject,'Visible','off');
[numeric,strings]=xlsread('puz.xlsx', 'sheet1', 'A1:N14');
a=1;
for x=20:30:620
for y=420:-30:30
Ebox(a)=uicontrol('Style','edit','position',[x y 30 30],'FontSize',20,'String',strings(a))
if string(a)==''
set(Ebox(a),'BackgroundColor','black')
end
a=a+1;
end
end

Respuesta aceptada

Walter Roberson
Walter Roberson el 18 de Sept. de 2015
You do not define "string". You do define "strings", but that output from xlsread() would be a cell array of strings so you would need {} indexing to access it:
if isempty(strings(a)) %(if you are checking for empty entry)
or
if strcmp(strings(a), ' ') %(if you are checking for blank)

Más respuestas (0)

Categorías

Más información sobre Word games en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by