Results 1 to 5 of 5

Thread: Two variables problem

Hybrid View

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2011
    Posts
    53

    Two variables problem

    I have a situation about assigning two variables bottom of any event

    For example,

    Private Sub cmd_esit_Click()
    num2 = Text1.Text
    If
    ...
    ...
    End If

    Dim A As Integer
    A = Text2.Text
    If
    ..
    ..
    End If


    Click event depends on num2 = Text1.Text

    When Text1.Text is clear, click event doesn't work

    I want two different event happen independently

  2. #2
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Two variables problem

    Maybe if you post your actual code it would help explain what the problem is?
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  3. #3
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: Two variables problem

    If Text1.Text is "clear", it has probably nothing entered to it. In this case you would set Num to nothing, what should happen with Num, what happens if Num is nothing?
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  4. #4

    Thread Starter
    Member
    Join Date
    Oct 2011
    Posts
    53

    Re: Two variables problem

    opus, I didn't understand what you meant

    I have a calculator and I want "=" button to calculate and to convert units each other. "=" calculates now but it doesn't convert unit each other. I don't want to make a new button for conversion




    These are codes:

    Private Sub cmd_equal_Click()
    sayi2 = Text1.Text
    If isaret = "+" Then
    Text1.Text = sayi1 + sayi2
    ElseIf isaret = "-" Then
    Text1.Text = sayi1 - sayi2
    ElseIf isaret = "*" Then
    Text1.Text = sayi1 * sayi2
    ElseIf isaret = "/" Then
    Text1.Text = sayi1 / sayi2
    ElseIf isaret = "^" Then
    Text1.Text = sayi1 ^ sayi2
    End If



    Private Sub Command1_Click()
    Dim A As Double, B As Double
    A = Text2.Text
    If Combo2.Text = "Degree" And Combo3.Text = "Radian" Then
    B = 3.1415926535898 * A / 180
    Text3.Text = B
    ElseIf Combo2.Text = "Degree" And Combo3.Text = "Degree" Then
    B = A
    Text3.Text = B
    ElseIf Combo2.Text = "Degree" And Combo3.Text = "Grad" Then
    B = 10 * A / 9
    Text3.Text = B
    ElseIf Combo2.Text = "Radian" And Combo3.Text = "Degree" Then
    B = 180 * A / 3.1415926535898
    Text3.Text = B
    ElseIf Combo2.Text = "Radian" And Combo3.Text = "Radian" Then
    B = A
    Text3.Text = B
    ElseIf Combo2.Text = "Radian" And Combo3.Text = "Grad" Then
    B = 200 * A / 3.1415926535898
    Text3.Text = B
    ElseIf Combo2.Text = "Grad" And Combo3.Text = "Grad" Then
    B = 9 * A / 10
    Text3.Text = B
    ElseIf Combo2.Text = "Grad" And Combo3.Text = "Radian" Then
    B = 3.1415926535898 * A / 200
    Text3.Text = B
    ElseIf Combo2.Text = "Grad" And Combo3.Text = "Grad" Then
    B = A
    Text3.Text = B
    End If
    End Sub
    Last edited by _MeRKeZ_; Nov 1st, 2011 at 12:36 AM.

  5. #5
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Two variables problem

    From your first post, I think your structure just wasn't correct....
    Code:
    If num2 = Val(Text1.Text) Then
        ' do your standard calculation
    Else
        ' do your conversion
    End If
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width