CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2011
    Posts
    4

    Unhappy help on making a save code

    (I posted what my form looks like)
    I'm having slight problems making my save code generator, which you enter your information into it, and it generates the save code for a game, but there are problems with some of the lines, which i have bolded

    Dim fa As Single
    Dim fb As Single
    Dim fc As Single
    Dim fd As Single
    Dim levelno As Single
    Dim clno As Single
    Dim colour As Single
    Dim skno As Single
    Dim skilllevel As Single
    Dim levelno2 As Single
    Dim unlocked As Single
    Dim nameleng As Single
    Dim username = TextBox1
    Dim savecode As Single
    Dim roundno As Single
    Dim clskno As Single


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    If CheckBox1.Checked = True Then
    fa = "Done"
    End If
    If CheckBox2.Checked = True Then
    fb = "Done"
    End If
    If CheckBox3.Checked = True Then
    fc = "Done"
    End If
    If CheckBox4.Checked = True Then
    fd = "Done"
    End If
    If fa = "Done" Then
    levelno = 0
    End If
    If fb = "Done" Then
    levelno = levelno + 2
    End If
    If fc = "Done" Then
    levelno = levelno + 4
    End If
    If fd = "Done" Then
    levelno = levelno + 8
    End If
    If colour = "Yellow" Then
    clno = 0
    End If
    If colour = "Orange" Then
    clno = 1
    End If
    If colour = "White" Then
    clno = 2
    End If
    If colour = "Blue" Then
    clno = 3
    End If
    If colour = "Green" Then
    clno = 4
    End If
    If colour = "Turquoise" Then
    clno = 5
    End If
    If (skilllevel = "Normal") Then
    skno = 0
    End If
    If (skilllevel = "Pro") Then
    skno = 1
    End If
    If (skilllevel = "Easy") Then
    skno = 2
    End If
    levelno2 = Chr(levelno + unlocked * 15 + 33)
    If levelno2 = "0" Then
    levelno2 = "z"
    End If
    nameleng = Chr(Number(username.length) + 8 * Rnd(3) + 65)
    levelno = Chr(levelno + 65)
    roundno = Chr(unlocked + 7 * Random(3) + 65)
    clskno = Chr(Number(skno) * 6 + (Number(clno) + 65))
    savecode = (username + "." + levelno2 + levelno + roundno + clskno + nameleng)
    Label8.Visible = True
    TextBox2.Visible = True
    If TextBox1.TextLength < 9 Then
    TextBox2.Text = savecode
    End If
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
    If ComboBox1.Text = "Orange" Then
    colour = "Orange"
    End If
    If ComboBox1.Text = "Blue" Then
    colour = "Blue"
    End If
    If ComboBox1.Text = "White" Then
    colour = "White"
    End If
    If ComboBox1.Text = "Green" Then
    colour = "Green"
    End If
    If ComboBox1.Text = "Turquoise" Then
    colour = "Turquoise"
    If ComboBox1.Text = "Yellow" Then
    colour = "Yellow"
    End If
    End If
    End Sub

    Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
    If ComboBox2.Text = "Easy" Then
    skilllevel = "Easy"
    End If
    If ComboBox2.Text = "Normal" Then
    skilllevel = "Normal"
    End If
    If ComboBox2.Text = "Pro" Then
    skilllevel = "Pro"
    End If
    End Sub
    Attached Images Attached Images  

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: help on making a save code

    That doesn't tell us WHAT the problem is, and the program doesn't sound like it's all that good, as in EVIL.
    Code:
    ' Use CODE TAGS also
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Feb 2011
    Posts
    4

    Unhappy Re: help on making a save code

    First of all, I'm only 13, pretty new at this, Second, my problems are:
    1. Value of type 'char' can't be converted into 'single'
    2. system.number is not accessible in this context because it is 'friend'

    The first one applies to the strings starting with chr, and the second one applies to the Number statements

  4. #4
    Join Date
    Feb 2011
    Posts
    4

    Exclamation Re: help on making a save code

    Probably should have had the coding specified, and the lines that have problems, so here:

    Code:
        Dim fa As Single
        Dim fb As Single
        Dim fc As Single
        Dim fd As Single
        Dim levelno As Single
        Dim clno As Single
        Dim colour As Single
        Dim skno As Single
        Dim skilllevel As Single
        Dim levelno2 As Single
        Dim unlocked As Single
        Dim nameleng As Single
        Dim username = TextBox1
        Dim savecode As Single
        Dim roundno As Single
        Dim clskno As Single
    
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            If CheckBox1.Checked = True Then
                fa = "Done"
            End If
            If CheckBox2.Checked = True Then
                fb = "Done"
            End If
            If CheckBox3.Checked = True Then
                fc = "Done"
            End If
            If CheckBox4.Checked = True Then
                fd = "Done"
            End If
            If fa = "Done" Then
                levelno = 0
            End If
            If fb = "Done" Then
                levelno = levelno + 2
            End If
            If fc = "Done" Then
                levelno = levelno + 4
            End If
            If fd = "Done" Then
                levelno = levelno + 8
            End If
            If colour = "Yellow" Then
                clno = 0
            End If
            If colour = "Orange" Then
                clno = 1
            End If
            If colour = "White" Then
                clno = 2
            End If
            If colour = "Blue" Then
                clno = 3
            End If
            If colour = "Green" Then
                clno = 4
            End If
            If colour = "Turquoise" Then
                clno = 5
            End If
            If (skilllevel = "Normal") Then
                skno = 0
            End If
            If (skilllevel = "Pro") Then
                skno = 1
            End If
            If (skilllevel = "Easy") Then
                skno = 2
            End If
            levelno2 = Chr(levelno + unlocked * 15 + 33)
            If levelno2 = "0" Then
                levelno2 = "z"
            End If
            nameleng = Chr(Number(username.length) + 8 * Rnd(3) + 65)
            levelno = Chr(levelno + 65)
            roundno = Chr(unlocked + 7 * Rnd(3) + 65)
            clskno = Chr(Number(skno) * 6 + (Number(clno) + 65))
            savecode = (username + "." + levelno2 + levelno + roundno + clskno + nameleng)
            Label8.Visible = True
            TextBox2.Visible = True
            If TextBox1.TextLength < 9 Then
                TextBox2.Text = savecode
            End If
        End Sub
    
        Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
            If ComboBox1.Text = "Orange" Then
                colour = "Orange"
            End If
            If ComboBox1.Text = "Blue" Then
                colour = "Blue"
            End If
            If ComboBox1.Text = "White" Then
                colour = "White"
            End If
            If ComboBox1.Text = "Green" Then
                colour = "Green"
            End If
            If ComboBox1.Text = "Turquoise" Then
                colour = "Turquoise"
                If ComboBox1.Text = "Yellow" Then
                    colour = "Yellow"
                End If
            End If
        End Sub
    
        Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
            If ComboBox2.Text = "Easy" Then
                skilllevel = "Easy"
            End If
            If ComboBox2.Text = "Normal" Then
                skilllevel = "Normal"
            End If
            If ComboBox2.Text = "Pro" Then
                skilllevel = "Pro"
            End If
        End Sub
    The bolded parts are the parts it says have problems

  5. #5
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: help on making a save code

    Code:
      Dim namelengCHR as STRING
      nameleng = Number(username.length) + 8 * Rnd(3) + 65
      namelengCHR = Chr(nameleng)
    Or, even add your IF statement logic in between the lines

    EDIT: Just noticed that you didn't declare nameleng as anything, which creates an OBJECT
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  6. #6
    Join Date
    Feb 2011
    Posts
    4

    Re: help on making a save code

    Ok I was an idiot, and set everything to single by accident, changed them to Strings, but there's still the Problem of the number thing, but while it will build if i replace with FormatNumber, it still returns an error.

  7. #7
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: help on making a save code

    Post your code. No need for your own method to format the print
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

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

Featured