Results 1 to 5 of 5

CLng apparently not working

Threaded View

  1. #1
    Forum Contributor
    Join Date
    02-01-2021
    Location
    Manchester
    MS-Off Ver
    365
    Posts
    220

    CLng apparently not working

    I have a userform where values in TextBoxes are used in calculations for other textboxes.
    I use the following code to do this.
    Private Sub CBCHOOOSE_Click()
    
    Dim GM1 As Long
    Dim GALY As Long
    Dim GTLY As Long
    Dim GLLY As Long
    With Sheets("Margins")
    .Unprotect
    
       With UserForm2
       
     GM1 = CLng(.TextBox2.Value)
     GALY = CLng(.TextBox1.Value)
     GTLY = CLng(.TextBox4.Value)
     GLLY = CLng(.TextBox5.Value)
     .TextBox6.Value = GM1 / GALY * GTLY
     .TextBox7.Value = GM1 / GALY * GLLY
     GM1 = CLng(TextBox3.Value)
    
     .TextBox8.Value = GM1 / GALY * GTLY
     .TextBox9.Value = GM1 / GALY * GLLY
    End With
    End Sub
    My problem is that TextBox2 has a value of ".46" but GM1 has a value of 0 and the other G values are either 0 or 1 The calculated values are all zeros
    What can be going wrong?
    Last edited by Osprey2; 01-03-2024 at 10:54 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Preventing An Error using CLng When Expression Contains Alpha
    By Jenn68 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-01-2019, 08:41 AM
  2. [SOLVED] CLng strange behaviour
    By ziomocci in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-08-2017, 04:16 AM
  3. [SOLVED] CLng help please
    By biznez in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-08-2016, 05:46 PM
  4. [SOLVED] Error message of CLng
    By gordonf35 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-11-2012, 05:21 PM
  5. [SOLVED] Prevent Clng from dropping Time off returned Serial value
    By bdb1974 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-27-2012, 04:44 PM
  6. VB Error in CLng
    By SMILE in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-26-2011, 03:48 AM
  7. Error using Clng function in vba to convert string to long data type
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-05-2011, 06:12 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1