HalilYanar Posted May 19, 2012 Share Posted May 19, 2012 (edited) Arkadaşlar aklımda bir proje vardı yaptım bitti fakat gördüm ki Inputların birine bile sayı değeri girilmeyince program kendi hatasını veriyor. Aşağıda ortalama bulma projesinin resmi ve .apz dosyası var; [img]http://i.imgur.com/AULlR.png[/img] .Apz : [quote]http://www.mediafire.com/?b45moknp1kfcm39[/quote] Veya ortalama butonundaki kodlar : [quote]a = Input.GetText("Input1"); b = Input.GetText("Input2"); c = Input.GetText("Input3"); d = Input.GetText("Input4"); e = Input.GetText("Input5"); f = Input.GetText("Input6"); g = Input.GetText("Input7"); h = Input.GetText("Input8"); i = Input.GetText("Input9"); u = Input.GetText("Input10"); y = Input.GetText("Input11"); m = Input.GetText("Input12"); t = Input.GetText("Input13"); n = Input.GetText("Input14"); mata = String.ToNumber(a) matb = String.ToNumber( matc = String.ToNumber(c) matd = String.ToNumber(d) mate = String.ToNumber(e) matf = String.ToNumber(f) matg = String.ToNumber(g) math = String.ToNumber(h) matj = String.ToNumber(i) mati = String.ToNumber(u) matk = String.ToNumber(y) matl = String.ToNumber(m) matm = String.ToNumber(t) matt = String.ToNumber(n) toplam = (a + b + c + d + e + f + g + h + i + u + y + m + t + n) bolum = (14) oran = (toplam / bolum) Input.SetText("Input16", oran)[/quote] Benim sorunum ise şu eğer inputların birine bile değer yani sayı girilmezse hata vericek. Üstadlarımın yardımlarını bekliyorum. Edited May 19, 2012 by HalilYanar Quote Link to comment Share on other sites More sharing options...
djonur007 Posted May 19, 2012 Share Posted May 19, 2012 Aşağıdaki örneği incele. [xml] sVeri = Input.GetText("Input1"); sDeger = Input.GetText("Input2"); if sVeri == "" and sDeger == "" then Dialog.Message("Notice", "Lütfen değer girin", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1); end[/xml] Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted May 19, 2012 Editor Share Posted May 19, 2012 (edited) for i = 1,14 do get = Input.GetText("Input"..i); if get == "" then Dialog.Message("Hata !","Lütfen "..i..". Notu giriniz.") break; end end Edited May 19, 2012 by pairs Quote Link to comment Share on other sites More sharing options...
djonur007 Posted May 19, 2012 Share Posted May 19, 2012 Ayrıca HalilYanar arkadaşım senin bu program eğer kodları yukarıda verdiğin gibiyse hata verir. Neden diyeceksin: Çünkü ben 5 tane ders notu girsem bile sen toplamı 14 e bölüyorsun. Buna dikkat et. Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted May 19, 2012 Editor Share Posted May 19, 2012 O yüzden hiç birisini boş geçirtmemek istiyor. Quote Link to comment Share on other sites More sharing options...
KintaRo Posted May 19, 2012 Share Posted May 19, 2012 verdiğiniz kodlar yanlış sonuca gider, çünkü arkadaşın dediği gibi 5 ders girse sonucu 5 e bölmesi gerek. [codebox]-- 14 input olduğu için 14 lük döngü nToplam = 0; nAdet = 0; for i=1,14 do sMetin = Input.GetText("Input" .. i) if sMetin ~= "" then nMetin = String.ToNumber(sMetin) nToplam = nToplam+nMetin nAdet = nAdet+1 end end -- eğer veri girişi yapilmissa if nAdet ~= 0 then Input.SetText("Input16", nToplam/nAdet) end[/codebox] projede birazda değişiklik yaptım. Inputlardaki maski kaldirip yerine kodla sayi girişi kontrolu koydum. tabi birde temizle buttonu. APZ: [quote]http://www.mediafire.com/?2jj7ng6wv06n2f7[/quote] Quote Link to comment Share on other sites More sharing options...
woramon Posted May 20, 2012 Share Posted May 20, 2012 (edited) KintaRo üstad düzenlediğin projeyi indirdim ama şu inputlarda ne yaptığını çözemedim. Zahmet olmassa az açıklayabilirmisin . AMS de yeni sayılırım kusura bakmayın Edit: Üstad sen sadece sayı girilmesini sağlarken backspace tusununda çalışmasını engellemissin herhangi bi imputa yanlış girince hepsini temizlemek gerekiyor... Edited May 20, 2012 by woramon Quote Link to comment Share on other sites More sharing options...
HalilYanar Posted May 20, 2012 Author Share Posted May 20, 2012 KintaRo abi sayende sorunu çözdüm. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.