Playing around with CDbl().

Lately I’ve been playing around with CDbl, but I’m unsure about something. If I’m not mistaken, CDbl can make a string look like an integer. I’m playing with some practice code. The program is a database where teams and players can be added. Before I add a new team into the database, I want to create a Team ID for them. While filling out the team information, the user can insert a team ID number manually or click a button to create an ID for them and it will appear in the team ID text field. Then the user clicks Save and it saves into the DB.

In the code below, I’ve Dim x As an Integer, however I’m not sure what extension I should add for the x so that the number appears in the text field. I’ve tried x.integer = CDbl(teamIDfield.text) but I get an error. For fun I tried x.text= CDbl(teamIDfield.text) it doesn’t work. For the textfield property, does the Super type (TextField vs TextArea) matter in this case?

P.S. Please excuse me if the code is wrong below. I haven’t been able to go further in playing with it because I can’t get past these errors mentioned above.

[code] Dim x As Integer
x = 50
If rs.Field(“id”).IntegerValue <> x Then
x = CDbl(teamIDfield.text)

  Else
    x =x + 1
    x = CDbl(teamIDfield.text)
  End If[/code]

If I understand correctly you want the interger X to be displayed in teamIDfield?

teamIDfield.text = Str(x)
      Dim x As Integer
      x = 50
      If rs.Field("id").IntegerValue <> x Then
        teamIDfield.text = Str(x)
        
      Else
        x = x + 1
        teamIDfield.text = Str(x)
      End If

Sorry If I missunderstood completeley :stuck_out_tongue:

[quote=195924:@Albin Kiland]If I understand correctly you want the interger X to be displayed in teamIDfield?

teamIDfield.text = Str(x)
      Dim x As Integer
      x = 50
      If rs.Field("id").IntegerValue <> x Then
        teamIDfield.text = Str(x)
        
      Else
        x = x + 1
        teamIDfield.text = Str(x)
      End If

Sorry If I missunderstood completeley :P[/quote]

Thanks for your reply. Yes, I’m trying to get the X into the teamIDfield. I’m away from my program now, but I’ll try it out once I return home. Your suggestion might be what I need to solve the problem.

Thanks @Albin Kiland! It works! :slight_smile: