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

조회 수: 6 (최근 30일)
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

채택된 답변

Walter Roberson
Walter Roberson 2015년 9월 18일
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)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Word games에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by