12 Replies - 671 Views - Last Post: 31 January 2013 - 11:02 PM Rate Topic: -----

#1 nicold  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 29-January 13

smallcap program with checkbox

Posted 29 January 2013 - 01:45 AM

hello i want to change the text in textbox1 to smallcaps or uppercase as soon as i check the checkbox with caption smallcaps or uppercase how can i do this please reply
Is This A Good Question/Topic? 0
  • +

Replies To: smallcap program with checkbox

#2 kai_itz me  Icon User is offline

  • D.I.C Head

Reputation: 28
  • View blog
  • Posts: 159
  • Joined: 03-August 12

Re: smallcap program with checkbox

Posted 29 January 2013 - 03:01 AM

firstly i will suggest you to use radiobutton instead of checkbox. and if you really want to use checkbox change (radiobutton to checkbox) rest will remain same. put this in a click event.

 If RadioButton1.Checked = True Then
            TextBox1.Text = TextBox1.Text.ToLower



        Elseif RadioButton2.Checked = True then
            TextBox1.Text = TextBox1.Text.ToUpper


        End If

This post has been edited by kai_itz me: 29 January 2013 - 03:33 AM

Was This Post Helpful? 0
  • +
  • -

#3 nicold  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 29-January 13

Re: smallcap program with checkbox

Posted 29 January 2013 - 03:28 AM

View Postkai_itz me, on 29 January 2013 - 03:01 AM, said:

firstly i will suggest you to use radiobutton instead of checkbox. and if you really want to use checkbox change (radiobutton to checkbox) rest will remain same. put this in a click event.

 If RadioButton1.Checked = True Then
            TextBox1.Text = TextBox1.Text.ToLower



        Else RadioButton2.Checked = True 
            TextBox1.Text = TextBox1.Text.ToUpper


        End If



no i couldn't get it properly please give me a clear code in with checkbox only please and i have send attachement please check
Was This Post Helpful? 0
  • +
  • -

#4 kai_itz me  Icon User is offline

  • D.I.C Head

Reputation: 28
  • View blog
  • Posts: 159
  • Joined: 03-August 12

Re: smallcap program with checkbox

Posted 29 January 2013 - 03:39 AM

i can't find your attachment... anyway for checkbox u can use this

 Private Sub Button1_Click()

If CheckBox1.Checked = True Then
            TextBox1.Text = TextBox1.Text.ToLower



        Elseif CheckBox2.Checked = True then
            TextBox1.Text = TextBox1.Text.ToUpper

        End If

End Sub



This post has been edited by kai_itz me: 29 January 2013 - 03:52 AM

Was This Post Helpful? 0
  • +
  • -

#5 kai_itz me  Icon User is offline

  • D.I.C Head

Reputation: 28
  • View blog
  • Posts: 159
  • Joined: 03-August 12

Re: smallcap program with checkbox

Posted 29 January 2013 - 03:49 AM

if you further want to apply some other conditions'' use this

    
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click        

If CheckBox1.Checked = True Then
            TextBox1.Text = TextBox1.Text.ToLower

        End If

        If CheckBox2.Checked = True Then
            TextBox1.Text = TextBox1.Text.ToUpper

        End If

        If (CheckBox1.Checked = True) And (CheckBox2.Checked = True) Then
            TextBox1.Text = "choose only one checkbox"

        End If
    End Sub


I FORGOT TO MENTION THE ABOVE CODE IS IN VB10...SORRY

This post has been edited by kai_itz me: 29 January 2013 - 04:32 AM

Was This Post Helpful? 0
  • +
  • -

#6 andrewsw  Icon User is offline

  • It's just been revoked!
  • member icon

Reputation: 3809
  • View blog
  • Posts: 13,508
  • Joined: 12-December 12

Re: smallcap program with checkbox

Posted 29 January 2013 - 04:45 AM

I VB6 you would use

TextBox1.Text = Ucase(TextBox1.Text)


and LCase.
Was This Post Helpful? 2
  • +
  • -

#7 kai_itz me  Icon User is offline

  • D.I.C Head

Reputation: 28
  • View blog
  • Posts: 159
  • Joined: 03-August 12

Re: smallcap program with checkbox

Posted 29 January 2013 - 04:52 AM

thanks for help mr. andrew :smile2:

Private Sub command1_Click()

        If Check1.Value = 1 Then
           Text1.Text = LCase(Text1.Text)

        End If

       If Check2.Value = 1 Then
            Text1.Text = UCase(Text1.Text)

        End If

        If (Check1.Value = 1) And (Check2.Value = 1) Then
           Text1.Text = "choose only one checkbox"

  End If

      
End Sub

This post has been edited by kai_itz me: 29 January 2013 - 04:54 AM

Was This Post Helpful? 0
  • +
  • -

#8 andrewsw  Icon User is offline

  • It's just been revoked!
  • member icon

Reputation: 3809
  • View blog
  • Posts: 13,508
  • Joined: 12-December 12

Re: smallcap program with checkbox

Posted 29 January 2013 - 05:09 AM

No worries. I'm not sure why you've switched from .checked to .value though?

If Check1.Value = 1 Then

(the value is more likely to be -1 anyway)
.checked should work:

If Check1.Checked Then

This post has been edited by andrewsw: 29 January 2013 - 05:10 AM

Was This Post Helpful? 0
  • +
  • -

#9 kai_itz me  Icon User is offline

  • D.I.C Head

Reputation: 28
  • View blog
  • Posts: 159
  • Joined: 03-August 12

Re: smallcap program with checkbox

Posted 29 January 2013 - 05:19 AM

Quote

No worries. I'm not sure why you've switched from .checked to .value though?


.checked not going to work in vb6 . it will give error

method or data member not found
ALSO

Quote

(the value is more likely to be -1 anyway)

it too will not work as i think for checkbox value
(true = 1 and false = 0)

THE ABOVE CODE IS PERFECTLY WORKING.

This post has been edited by kai_itz me: 29 January 2013 - 05:27 AM

Was This Post Helpful? 1
  • +
  • -

#10 andrewsw  Icon User is offline

  • It's just been revoked!
  • member icon

Reputation: 3809
  • View blog
  • Posts: 13,508
  • Joined: 12-December 12

Re: smallcap program with checkbox

Posted 29 January 2013 - 05:45 AM

Thank you. My mistake! MSDN reference.

VB6 uses .value rather than .checked and being checked has the value 1 (or vbChecked) rather than the boolean true/-1.

This post has been edited by andrewsw: 29 January 2013 - 05:47 AM

Was This Post Helpful? 0
  • +
  • -

#11 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 303
  • View blog
  • Posts: 1,797
  • Joined: 26-March 09

Re: smallcap program with checkbox

Posted 29 January 2013 - 06:41 AM

Alternatively, you could use the constants vbChecked, vbUnchecked or vbGrayed to make your code a bit more readable.

Just my preference as I can never remember what the numbers relate to. :)/>

This post has been edited by maj3091: 29 January 2013 - 06:42 AM

Was This Post Helpful? 0
  • +
  • -

#12 kai_itz me  Icon User is offline

  • D.I.C Head

Reputation: 28
  • View blog
  • Posts: 159
  • Joined: 03-August 12

Re: smallcap program with checkbox

Posted 29 January 2013 - 08:52 PM

Thanks guyz for further clearification..
Was This Post Helpful? 0
  • +
  • -

#13 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: smallcap program with checkbox

Posted 31 January 2013 - 11:02 PM

View Postandrewsw, on 29 January 2013 - 06:45 AM, said:

Thank you. My mistake! MSDN reference.

VB6 uses .value rather than .checked and being checked has the value 1 (or vbChecked) rather than the boolean true/-1.

The reason that it isn't a boolean value is because there are three possible values, as maj has pointed out. If you convert the value to boolean you will get -1 for both checked and grayed, and 0 for unchecked. I still remember struggling with this back in the VB4 days. :)

This post has been edited by BobRodes: 31 January 2013 - 11:04 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1