Textgadget

Anfängerfragen zum Programmieren mit PureBasic.
Benutzeravatar
R4z0r1989
Beiträge: 521
Registriert: 12.06.2005 18:06
Kontaktdaten:

Textgadget

Beitrag von R4z0r1989 »

Ich hab mal wieder ein Problem und zwar wenn ich ein Textgadget definiere, und bei jedem Klick auf a soll er +1 machen aber dann fügt er immer hinzu also:



..............:....Wie es ist...................wie es sein soll
kein klick:.........0.....................................0......
1. Klick...:.........01...................................2......
2. Klick...:.........011.................................3......
......................................................................

Code: Alles auswählen

If EventwParam() = #VK_a
      SetGadgetText(1,"")
      A$=(A$+"1")
      SetGadgetText(1,A$)
    EndIf
Benutzeravatar
zigapeda
Beiträge: 1753
Registriert: 06.03.2005 17:22
Wohnort: Kaufbeuren
Kontaktdaten:

Beitrag von zigapeda »

also:

Code: Alles auswählen

If EventwParam() = #VK_a
  A$ = GetGadgetText(1)
  A$ = Str(Val(A$) + 1)
  SetGadgetText(1,A$)
EndIf 
und noch ein tipp:
zwischen codetags ist jedes zeichen gleich lang:

Code: Alles auswählen

             Wie es ist     wie es sein soll
kein klick : 0              0
1. Klick   : 01             2
2. Klick   : 011            3 
kluger Mann + kluge Frau = Romanze | dummer Mann + dumme Frau = Schwangerschaft
kluger Mann + dumme Frau = Affäre | dummer Mann + kluge Frau = Shopping <)
Benutzeravatar
MVXA
Beiträge: 3823
Registriert: 11.09.2004 00:45
Wohnort: Bremen, Deutschland
Kontaktdaten:

Beitrag von MVXA »

Und noch ein Tipp:
String Operationen niemals in () Klammern schreiben wie du es hier getan
hast:

Code: Alles auswählen

(A$+"1")
Bild
Benutzeravatar
R4z0r1989
Beiträge: 521
Registriert: 12.06.2005 18:06
Kontaktdaten:

Beitrag von R4z0r1989 »

Danke für die Antworten aber ich hab noch ne Frage und zwar wie kann ich ein ä ansprechen

Code: Alles auswählen

#VK_a
;so nimmt er es
#VK_ä
;so nicht. Wie dann

Danke für eure Antworten und für die folgenden!!!
Christi
Beiträge: 154
Registriert: 31.08.2004 14:17
Kontaktdaten:

Beitrag von Christi »

damit:

Code: Alles auswählen

#vk_ae = $DE ;#VK_OEM_7
Benutzeravatar
R4z0r1989
Beiträge: 521
Registriert: 12.06.2005 18:06
Kontaktdaten:

Beitrag von R4z0r1989 »

geht nicht
ich poste ma den ganzen code:

Code: Alles auswählen

OpenWindow(0, 0, 0, 500, 680, #PB_Window_ScreenCentered | #PB_Window_SystemMenu, "Test") 


A$="0"
B$="0"
C$="0"
D$="0"
E$="0"
F$="0"
G$="0"
H$="0"
I$="0"
J$="0"
K$="0"
L$="0"
M$="0"
N$="0"
O$="0"

P$="0"
Q$="0"
R$="0"
S$="0"
T$="0"
U$="0"
V$="0"
W$="0"
X$="0"
Y$="0"
Z$="0"
AE$="0"
OE$="0"
UE$="0"




For A=0 To 10000
For B=0 To 10000   
For C=0 To 10000
For D=0 To 10000
For E=0 To 10000   
For F=0 To 10000
For G=0 To 10000
For H=0 To 10000   
For I=0 To 10000
For J=0 To 10000
For K=0 To 10000   
For L=0 To 10000
For M=0 To 10000   
For N=0 To 10000
For O=0 To 10000

For P=0 To 10000
For Q=0 To 10000   
For R=0 To 10000
For S=0 To 10000
For T=0 To 10000   
For U=0 To 10000
For V=0 To 10000
For W=0 To 10000   
For X=0 To 10000
For Y=0 To 10000
For Z=0 To 10000   
For AE=0 To 10000
For OE=0 To 10000   
For UE=0 To 10000




If CreateGadgetList(WindowID())


;Texts

TextGadget(1001,28,02,50,15,"A")
TextGadget(1002,28,47,50,15,"B")
TextGadget(1003,28,92,50,15,"C")
TextGadget(1004,28,137,50,15,"D")
TextGadget(1005,28,182,50,15,"E")
TextGadget(1006,28,227,50,15,"F")
TextGadget(1007,28,272,50,15,"G")
TextGadget(1008,28,317,50,15,"H")
TextGadget(1009,28,362,50,15,"I")
TextGadget(1010,28,407,50,15,"J")
TextGadget(1011,28,452,50,15,"K")
TextGadget(1012,28,497,50,15,"L")
TextGadget(1013,28,542,50,15,"M")
TextGadget(1014,28,587,50,15,"N")
TextGadget(1015,28,632,50,15,"O")

TextGadget(1016,108,02,50,15,"P")
TextGadget(1017,108,47,50,15,"Q")
TextGadget(1018,108,92,50,15,"R")
TextGadget(1019,108,137,50,15,"S")
TextGadget(1020,108,182,50,15,"T")
TextGadget(1021,108,227,50,15,"U")
TextGadget(1022,108,272,50,15,"V")
TextGadget(1023,108,317,50,15,"W")
TextGadget(1024,108,362,50,15,"X")
TextGadget(1025,108,407,50,15,"Y")
TextGadget(1026,108,452,50,15,"Z")
TextGadget(1000,108,497,50,15,"")
TextGadget(1027,108,542,50,15,"Ä")
TextGadget(1028,108,587,50,15,"Ö")
TextGadget(1029,108,632,50,15,"Ü")





;Strings


StringGadget(1,10,15,50,20,A$,#PB_String_ReadOnly)
StringGadget(2,10,60,50,20,B$,#PB_String_ReadOnly)
StringGadget(3,10,105,50,20,C$,#PB_String_ReadOnly)
StringGadget(4,10,150,50,20,D$,#PB_String_ReadOnly)
StringGadget(5,10,195,50,20,E$,#PB_String_ReadOnly)
StringGadget(6,10,240,50,20,F$,#PB_String_ReadOnly)
StringGadget(7,10,285,50,20,g$,#PB_String_ReadOnly)
StringGadget(8,10,330,50,20,h$,#PB_String_ReadOnly)
StringGadget(9,10,375,50,20,i$,#PB_String_ReadOnly)
StringGadget(10,10,420,50,20,j$,#PB_String_ReadOnly)
StringGadget(11,10,465,50,20,k$,#PB_String_ReadOnly)
StringGadget(12,10,510,50,20,l$,#PB_String_ReadOnly)
StringGadget(13,10,555,50,20,m$,#PB_String_ReadOnly)
StringGadget(14,10,600,50,20,n$,#PB_String_ReadOnly)
StringGadget(15,10,645,50,20,o$,#PB_String_ReadOnly)

StringGadget(16,90,15,50,20,p$,#PB_String_ReadOnly)
StringGadget(17,90,60,50,20,q$,#PB_String_ReadOnly)
StringGadget(18,90,105,50,20,r$,#PB_String_ReadOnly)
StringGadget(19,90,150,50,20,s$,#PB_String_ReadOnly)
StringGadget(20,90,195,50,20,t$,#PB_String_ReadOnly)
StringGadget(21,90,240,50,20,u$,#PB_String_ReadOnly)
StringGadget(22,90,285,50,20,v$,#PB_String_ReadOnly)
StringGadget(23,90,330,50,20,w$,#PB_String_ReadOnly)
StringGadget(24,90,375,50,20,x$,#PB_String_ReadOnly)
StringGadget(25,90,420,50,20,y$,#PB_String_ReadOnly)
StringGadget(26,90,465,50,20,z$,#PB_String_ReadOnly)

StringGadget(27,90,555,50,20,ae$,#PB_String_ReadOnly)
StringGadget(28,90,600,50,20,oe$,#PB_String_ReadOnly)
StringGadget(29,90,645,50,20,ue$,#PB_String_ReadOnly)




EndIf




Repeat 
ereignis.l = WaitWindowEvent() 
  
  If ereignis.l = #wm_keydown 
    
    
    If EventwParam() = #VK_a
      A+1
      A$=Str(A)
      SetGadgetText(1,A$)
    EndIf
    
    If EventwParam() = #VK_b 
      B+1
      B$=Str(B)
      SetGadgetText(2,B$) 
    EndIf
    
    If EventwParam() = #VK_c 
      c+1
      c$=Str(c)
      SetGadgetText(3,c$) 
    EndIf
    
    If EventwParam() = #VK_d
      d+1
      d$=Str(d)
      SetGadgetText(4,d$)
    EndIf
    
    If EventwParam() = #VK_e 
      e+1
      e$=Str(e)
      SetGadgetText(5,e$) 
    EndIf
    
    If EventwParam() = #VK_f 
      f+1
      f$=Str(f)
      SetGadgetText(6,f$) 
    EndIf
    
    If EventwParam() = #VK_g
      g+1
      g$=Str(g)
      SetGadgetText(7,g$)
    EndIf
    
    If EventwParam() = #VK_h 
      h+1
      h$=Str(h)
      SetGadgetText(8,h$) 
    EndIf
    
    If EventwParam() = #VK_i 
      i+1
      i$=Str(i)
      SetGadgetText(9,i$) 
    EndIf
    
    If EventwParam() = #VK_j
      j+1
      j$=Str(j)
      SetGadgetText(10,j$)
    EndIf
    
    If EventwParam() = #VK_k 
      k+1
      k$=Str(e)
      SetGadgetText(11,k$) 
    EndIf
    
    If EventwParam() = #VK_l 
      l+1
      l$=Str(l)
      SetGadgetText(12,l$) 
    EndIf
    
    If EventwParam() = #VK_m
      m+1
      m$=Str(m)
      SetGadgetText(13,m$)
    EndIf
    
    If EventwParam() = #VK_n 
      n+1
      n$=Str(n)
      SetGadgetText(14,n$) 
    EndIf
    
    If EventwParam() = #VK_o 
      o+1
      o$=Str(o)
      SetGadgetText(15,o$) 
    EndIf
    
    If EventwParam() = #VK_p
      p+1
      p$=Str(p)
      SetGadgetText(16,p$)
    EndIf
    
    If EventwParam() = #VK_q 
      q+1
      q$=Str(q)
      SetGadgetText(17,q$) 
    EndIf
    
    If EventwParam() = #VK_r 
      r+1
      r$=Str(r)
      SetGadgetText(18,r$) 
    EndIf
    
    If EventwParam() = #VK_s
      s+1
      s$=Str(s)
      SetGadgetText(19,s$)
    EndIf
    
    If EventwParam() = #VK_t 
      t+1
      t$=Str(t)
      SetGadgetText(20,t$) 
    EndIf
    
    If EventwParam() = #VK_u 
      u+1
      u$=Str(u)
      SetGadgetText(21,u$) 
    EndIf
    
    If EventwParam() = #VK_v
      v+1
      v$=Str(v)
      SetGadgetText(22,v$)
    EndIf
    
    If EventwParam() = #VK_w 
      w+1
      w$=Str(w)
      SetGadgetText(23,w$) 
    EndIf
    
    If EventwParam() = #VK_x 
      x+1
      x$=Str(x)
      SetGadgetText(24,x$) 
    EndIf
    
    If EventwParam() = #VK_y
      y+1
      y$=Str(y)
      SetGadgetText(25,y$)
    EndIf
    
    If EventwParam() = #VK_z 
      z+1
      z$=Str(e)
      SetGadgetText(26,z$) 
    EndIf
    
    If EventwParam() = #vk_ae 
      ae+1
      ae$=Str(ae)
      SetGadgetText(27,ae$) 
    EndIf
    
    If EventwParam() = #VK_oe
      oe+1
      oe$=Str(oe)
      SetGadgetText(28,oe$)
    EndIf
    
    If EventwParam() = #VK_ue 
      ue+1
      ue$=Str(ue)
      SetGadgetText(29,ue$) 
    EndIf
    

     
  EndIf 


Until ereignis.l = #PB_Event_CloseWindow
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
Christi
Beiträge: 154
Registriert: 31.08.2004 14:17
Kontaktdaten:

Beitrag von Christi »

du musst die von mir gepostete zeile natürlich auch in deinen code einfügen sonst gibts die konstante #vk_ae nicht

hier noch ein paar:

Code: Alles auswählen

#vk_ae    = $DE ;#VK_OEM_7
#vk_oe    = $C0 ;#VK_OEM_3
#vk_ue    = $BA ;#VK_OEM_1
#vk_sz    = $DB ;#VK_OEM_4

#vk_raute = $BF ;#VK_OEM_2

#vk_punkt = $BE;#VK_OEM_PERIOD
#vk_komma = $BC;#VK_OEM_COMMA
Benutzeravatar
R4z0r1989
Beiträge: 521
Registriert: 12.06.2005 18:06
Kontaktdaten:

Beitrag von R4z0r1989 »

Das ist mein erstes selcst gemachtes Programm.
Also wo ich nix von andren hab.Aber bin ich hier der einzige.
Oder kommt es mir nur so vor.
aber ich finde es irgendwie sinnlos!!!!
Benutzeravatar
Kiffi
Beiträge: 10719
Registriert: 08.09.2004 08:21
Wohnort: Amphibios 9

Beitrag von Kiffi »

> aber ich finde es irgendwie sinnlos!!!!

sinnlos sind die For-Next-Schleifen.
a²+b²=mc²
Benutzeravatar
R4z0r1989
Beiträge: 521
Registriert: 12.06.2005 18:06
Kontaktdaten:

Beitrag von R4z0r1989 »

wie soll ich es denn machen.
Wie gesagt bin anfänger und lerne gerne also bitte sagt mir nicht nur was ich falsch mache sondern auch was ich besser machen kann.
Antworten