اطلاعیه

Collapse
No announcement yet.

VB question

Collapse
X
 
  • Filter
  • زمان
  • Show
Clear All
new posts

  • VB question

    agha sharmande 1 soale maskhare daram:D
    bara hex be rahaty mishe ba dastoore hex(....) be hex beresim bara decimal abyad chikar ****m?rahe sadee has?

  • #2
    MSDN maghe nasb nakardi ?


    HOWTO: Convert Decimal Integers to Hexadecimal Strings
    ID: Q192303



    --------------------------------------------------------------------------------
    The information in this article applies to:

    Microsoft Visual FoxPro for Windows, versions 5.0, 5.0a, 6.0

    --------------------------------------------------------------------------------


    SUMMARY
    The following Microsoft Knowledge Base article describes how to convert decimal integers to a hexadecimal string:

    Q95717 How to Convert Decimal Numbers to Hexadecimal Numbers


    However, the function in the article is limited in the size of the integer it can convert. In Visual FoxPro, the TRANSFORM() function can be used to convert decimal integers to hexadecimal strings. However, TRANSFORM() cannot handle negative decimal integers (for example, TRANSFORM(-2, "@0")).

    This article demonstrates how to use the DecToHex function to convert any decimal integer (up to DWORD in size) to a hexadecimal string, regardless of the sign of the integer.



    MORE INFORMATION
    The following code demonstrates how to use the DecToHex() function to convert decimal integers to a string containing the equivalent hexadecimal number.

    Sample Code

    *-- Code begins here.
    WAIT WINDOW "-" + STR(2146828218) + " = " + DecToHex(-2146828218)
    WAIT WINDOW STR(-43690) + " = " + DecToHex(-43690)
    WAIT WINDOW STR(43690) + " = " + DecToHex(43690)

    *-----------------------------------------------------------------
    *- Function: DecToHex
    *- Summary: Converts decimal integers to hex strings, whether
    *- signed or unsigned.
    *- Parameters: liDecNumber - decimal number to convert.
    *-----------------------------------------------------------------
    FUNCTION DecToHex
    PARAMETERS liDecNumber
    lsHexNumber = ""
    IF liDecNumber > 0 && It's not negative, so do a straight TRANSFORM.
    lsHexNumber = TRANSFORM(liDecNumber, "@0")
    ELSE

    *-- The number is negative, so we'll have to do a little more work,
    *-- since it's not as straight forward as converting and adding a
    *-- minus sign.

    *-- Find the length of the resulting hex string.
    lsHexNumber = TRANSFORM(ABS(liDecNumber), "@0")
    IF SUBSTR(lsHexNumber, 3, 1) = "0" && The number has filled the
    && eight places of DWORD.
    liLength = LEN(SUBSTR(lsHexNumber, NotAt("0", lsHexNumber, 2)))
    ELSE
    *-- Subtract to account for "0x".
    liLength = LEN(TRANSFORM(ABS(liDecNumber), "@0")) - 2
    ENDIF

    lsTempHex = 0xFFFFFFFF
    lsHexNumber = TRANSFORM(lsTempHex-ABS(liDecNumber) + 1, "@0")
    ENDIF
    RETURN lsHexNumber

    *-----------------------------------------------------------------
    *- Function: NotAt
    *- Summary: From within a passed string, finds the first
    *- occurrence of a character that is not the character
    *- specified. In other words, this function works
    *- opposite of the manner that AT() does.
    *- Parameters: lsNotString - What we don't want. The function
    *- finds the first character that is
    *- not lsNotString.
    *- lsSearchString - The string in which to search.
    *- liOccurence - Indicates that NotAt should find
    *- the liOccurence of a character
    *- that is not lsNotString.
    *-----------------------------------------------------------------
    FUNCTION NotAt()
    PARAMETERS lsNotString, lsSearchString, liOccurrence

    llFound = .F. && Flag indicates if we've found a character that
    && is NOT lsNotString
    llEndOfString = .F. && Flag to indicate that we've reached the end
    && of the string.
    lnCounter = 0 && Tracks position during the search.
    lnLength = LEN(lsSearchString)
    liOccurCount = 0 && Tracks how many occurrences have been found.

    *-- Loop until the desired character is found or the end of
    *-- the string is reached.
    DO WHILE NOT llFound AND NOT llEndofString
    lnCounter = lnCounter + 1
    lsCompare = SUBSTR(lsSearchString, lnCounter, 1)
    IF lsCompare <> lsNotString
    liOccurCount = liOccurCount + 1

    *-- Have we found the occurrence we want?
    IF liOccurCount = liOccurrence
    llFound = .T.
    ENDIF
    ENDIF
    IF lnCounter = lnLength
    llEndOfString = .T.
    ENDIF

    ENDDO
    RETURN lnCounter
    *-- Code ends here.



    REFERENCES
    For additional information, please see the following articles in the Microsoft Knowledge Base:

    Q95717 How to Convert Decimal Numbers to Hexadecimal Numbers
    Q155389 How To Convert Values to Hexadecimal Format with Xbase
    (c) Microsoft Corporation 1998. All Rights Reserved. Contributions by Mike A. Stewart, Microsoft Corporation.

    Additional query words: kbVFp500a kbVFp500 kbVFp600 kbXBase


    Keywords :
    Version : WINDOWS:5.0,5.0a,6.0
    Platform : WINDOWS
    Issue type : kbhowto
    http://blxk.shabgard.org

    Comment


    • #3
      be bakhshid awali Fox bood cancel zadama wali kar az kar ghozashte bood ;)

      Val Function


      Returns the numbers contained in a string as a numeric value of appropriate type.

      Syntax

      Val(string)

      The required string argument is any valid string expression.

      Remarks

      The Val function stops reading the string at the first character it can't recognize as part of a number. Symbols and characters that are often considered parts of numeric values, such as dollar signs and commas, are not recognized. However, the function recognizes the radix prefixes &O (for octal) and &H (for hexadecimal). Blanks, tabs, and linefeed characters are stripped from the argument.

      The following returns the value 1615198:

      Val(" 1615 198th Street N.E.")

      In the code below, Val returns the decimal value -1 for the hexadecimal value shown:

      Val("&HFFFF")

      Note The Val function recognizes only the period (.) as a valid decimal separator. When different decimal separators are used, as in international applications, use CDbl instead to convert a string to a number.
      http://blxk.shabgard.org

      Comment


      • #4
        motavajeh nashodam akhe val ke inkaro nemikone mikham 1 keygen besazam vase in mikham

        man 1 chizi neveshtam vali kamel nis
        tabdile mabna dige aval hexro migire age A bood arayaro mikone 10...
        bad masalan age bood
        A1
        1*16^0+10*16^1 mikone
        vali eroor mide:D

        Private Sub Command1_Click()
        Dim a(20) As String
        For i = Len(Text1) - 1 To 0 Step -1
        'For i = 0 To Len(Text1)
        a(i) = Mid(Text1, i + 1, 1)
        MsgBox ("a(" & i & ")= " & a(i))
        Next i

        For i = 0 To Len(Text1) - 1
        Select Case Mid(Text1, i + 1, 1)
        Case "A"
        a(i) = 10
        Case "B"
        a(i) = 11
        Case "C"
        a(i) = 12
        Case "D"
        a(i) = 13
        Case "E"
        a(i) = 14
        Case "F"
        a(i) = 15
        End Select
        Next i

        For i = Len(Text1) - 1 To 0 Step -1
        'MsgBox a(i)
        dec = dec + (a(i + 1) * (16 ^ i))
        MsgBox ("a(" & i & ")= " & a(i))
        MsgBox dec
        Next i



        End Sub

        Comment


        • #5
          agha mamnoon neveshtam:D

          Private Sub Command1_Click()
          Dim a(20) As String
          For i = 0 To Len(Text1) - 1
          a(i) = Mid(Text1, i + 1, 1)
          Next i
          For i = 0 To Len(Text1) - 1
          Select Case Mid(Text1, i + 1, 1)
          Case "A"
          a(i) = 10
          Case "B"
          a(i) = 11
          Case "C"
          a(i) = 12
          Case "D"
          a(i) = 13
          Case "E"
          a(i) = 14
          Case "F"
          a(i) = 15
          End Select
          Next i
          For i = 0 To Len(Text1) - 1
          dec = dec + (a(i) * 16 ^ (Len(Text1) - i - 1))
          Next i
          Text2 = dec
          End Sub

          Comment


          • #6
            سلام به همه
            من تازه دارم vb ياد ميگيرم
            يه سؤال داشتم نخواستم تاپيک جديد باز کنم اين تاپيک مال عصر حجر رو بالا اوردم
            يه برنامه ساده واسه جمع دو عدد نوشتم
            وقت کامپايل اين ارور رو ميگيرم واسه رفعش چيکار کنم؟

            کد:
            ------ Build started: Project: WindowsApplication5, Configuration: Debug Any CPU ------
            D:\WINDOWS\Microsoft.NET\Framework\v3.5\Vbc.exe /noconfig /imports:Microsoft.VisualBasic,System,System.Collections,System.Collections.Generic,System.Data,System.Drawing,System.Diagnostics,System.Windows.Forms,System.Linq,System.Xml.Linq /optioncompare:Binary /optionexplicit+ /optionstrict:custom /nowarn:42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 /optioninfer+ /rootnamespace:WindowsApplication5 /doc:obj\Debug\WindowsApplication5.xml /define:"CONFIG=\"Debug\",DEBUG=-1,TRACE=-1,_MyType=\"WindowsForms\",PLATFORM=\"AnyCPU\"" /reference:"D:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll","D:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.DataSetExtensions.dll",D:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll,D:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Deployment.dll,D:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll,D:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll,D:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll,D:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll,"D:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll" /main:WindowsApplication5.My.MyApplication /debug+ /debug:full /filealign:512 /out:obj\Debug\WindowsApplication5.exe /resource:obj\Debug\WindowsApplication5.Form1.resources /resource:obj\Debug\WindowsApplication5.Resources.resources /target:winexe Form1.vb Form1.Designer.vb "My Project\AssemblyInfo.vb" "My Project\Application.Designer.vb" "My Project\Resources.Designer.vb" "My Project\Settings.Designer.vb"
            D:\Documents and Settings\.........\Visual Studio 2008\Projects\WindowsApplication5\WindowsApplication5\Form1.vb(8) : error BC30456: 'caption' is not a member of 'System.Windows.Forms.Label'.
            ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

            Comment


            • #7
              نوشته اصلی توسط al_omid نمایش پست ها
              سلام به همه
              من تازه دارم vb ياد ميگيرم
              يه سؤال داشتم نخواستم تاپيک جديد باز کنم اين تاپيک مال عصر حجر رو بالا اوردم
              يه برنامه ساده واسه جمع دو عدد نوشتم
              وقت کامپايل اين ارور رو ميگيرم واسه رفعش چيکار کنم؟

              کد:
              ------ Build started: Project: WindowsApplication5, Configuration: Debug Any CPU ------
              D:\WINDOWS\Microsoft.NET\Framework\v3.5\Vbc.exe /noconfig /imports:Microsoft.VisualBasic,System,System.Collections,System.Collections.Generic,System.Data,System.Drawing,System.Diagnostics,System.Windows.Forms,System.Linq,System.Xml.Linq /optioncompare:Binary /optionexplicit+ /optionstrict:custom /nowarn:42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 /optioninfer+ /rootnamespace:WindowsApplication5 /doc:obj\Debug\WindowsApplication5.xml /define:"CONFIG=\"Debug\",DEBUG=-1,TRACE=-1,_MyType=\"WindowsForms\",PLATFORM=\"AnyCPU\"" /reference:"D:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll","D:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.DataSetExtensions.dll",D:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll,D:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Deployment.dll,D:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll,D:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll,D:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll,D:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll,"D:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll" /main:WindowsApplication5.My.MyApplication /debug+ /debug:full /filealign:512 /out:obj\Debug\WindowsApplication5.exe /resource:obj\Debug\WindowsApplication5.Form1.resources /resource:obj\Debug\WindowsApplication5.Resources.resources /target:winexe Form1.vb Form1.Designer.vb "My Project\AssemblyInfo.vb" "My Project\Application.Designer.vb" "My Project\Resources.Designer.vb" "My Project\Settings.Designer.vb"
              D:\Documents and Settings\.........\Visual Studio 2008\Projects\WindowsApplication5\WindowsApplication5\Form1.vb(8) : error BC30456: 'caption' is not a member of 'System.Windows.Forms.Label'.
              ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

              از وی بی 2008 استفاده میکنی ؟
              کد رو یزار برات کامپایل میکنم

              Comment


              • #8
                بعد از 3 سال تاپیک اوردی بالا؟

                Comment


                • #9
                  نوشته اصلی توسط Mormoroth نمایش پست ها
                  بعد از 3 سال تاپیک اوردی بالا؟
                  آهای مرده متحرک دقت کن ببین میگه نخواستم تاپیک جدید باز کنم توام بجا گیر دادن بیا کمکش کن

                  Comment


                  • #10
                    نوشته اصلی توسط ashi_bomba2006 نمایش پست ها
                    از وی بی 2008 استفاده میکنی ؟
                    کد رو یزار برات کامپایل میکنم
                    سلام ممنون
                    اگه ميخواستم کسی کامپايل کنه که ميدادم بهتون
                    نه از Visual Studio 2008 استفاده ميکنم
                    ظاهراً به فايلای اجرايی گير داده انگار پيدا نکنه..
                    کد:
                    Reference Assemblies\Microsoft\Framework\[COLOR="Red"]v3.5\System.Core.dll[/COLOR]
                    نميدونم من که تازه کارم سر در نميارم
                    يه گير ديگه که داده به دستور caption هست
                    کد:
                    'caption' is not a member of 'System.Windows.Forms.Label'.
                    نکنه چون با وی بی کامپايل نکردم گير داده؟؟؟ :D

                    شعر گفتم؟ :D

                    Comment


                    • #11
                      اگه مي خواي visual basic6 ياد بگيري نصب visual studio ورژن سال 98 اولين قدم هست
                      اما اگه مي خواي بري ويژوال بيسيك دات نت ياد بگيري كه اون يه چيز ديگس
                      -------احتمالا با اون كامپايلر كه گفتم برنامه درست كار ميكنه
                      براي اينكه بهتر بشه راهنمايي كرد برنامه رو اينجا بذار
                      Last edited by m2000; 07-20-2008, 04:59 PM.
                      چه کسی میگوید که گرانی اینجاست؟؟؟
                      همه جا ارزانی است...
                      چه شرافت ارزان
                      تن عریان ارزان
                      و دروغ از همه ارزان تر
                      وچه تخفیف بزرگی خورده است قیمت هر انسان

                      Comment


                      • #12
                        نوشته اصلی توسط m2000 نمایش پست ها
                        اگه مي خواي visual basic6 ياد بگيري نصب visual studio ورژن سال 98 اولين قدم هست
                        اما اگه مي خواي بري ويژوال بيسيك دات نت ياد بگيري كه اون يه چيز ديگس
                        -------احتمالا با اون كامپايلر كه گفتم برنامه درست كار ميكنه
                        براي اينكه بهتر بشه راهنمايي كرد برنامه رو اينجا بذار
                        اين برنامه تو visual studio 2008 کامپايل نشد اما تو VB6 شد
                        چيزی نبود يه برنامه جمع ساده بود
                        کد:
                        Public Class Form1
                        
                            Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
                        Dim x As Integer,y az integer,z as integer
                                X = Val(textbox1.text)
                                Y = Val(textbox2.text)
                                z = X + y
                                label1.caption = Str$(z)
                            End Sub
                        End Class

                        Comment


                        • #13
                          سلام رفیقا یه تیکه کد php دارم برای decoding پسورد سیو شده تو regedit هست اگر کسی php بلده خواهشن برام به vb کامپیل کنه ;) کد از قراره زیر هست
                          کد:
                          function yahoo64_encode($source) 
                          { 
                            $yahoo64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._"; 
                            $limit=strlen($source)-(strlen($source)%3); 
                            $dest=""; 
                            for($i=0;$i<$limit;$i+=3) 
                            { 
                              $dest.=$yahoo64[ord($source[$i])>>2]; 
                              $dest.=$yahoo64[((ord($source[$i])<<4)&0x30) | (ord($source[$i+1])>>4)]; 
                              $dest.=$yahoo64[((ord($source[$i+1])<<2)&0x3C) | (ord($source[$i+2])>>6)]; 
                              $dest.=$yahoo64[ord($source[$i+2])&0x3F]; 
                            } 
                          
                            switch(strlen($source)-$limit) 
                            { 
                              case 1: 
                              { 
                                $dest.=$yahoo64[ord($source[$i])>>2]; 
                                $dest.=$yahoo64[(ord($source[$i])<<4)&0x30]; 
                                $dest.='--'; 
                              } break; 
                          
                              case 2: 
                              { 
                                $dest.=$yahoo64[ord($source[$i])>>2]; 
                                $dest.=$yahoo64[((ord($source[$i])<<4)&0x30) | (ord($source[$i+1])>>4)]; 
                                $dest.=$yahoo64[((ord($source[$i+1])<<2)&0x3c)]; 
                                $dest.='-'; 
                              } break; 
                            } 
                            return($dest); 
                          } 
                          
                          function Index($string,$chr) 
                          { 
                            for($i=0;$i<64;$i++) { if($string[$i]==$chr) { return($i); } } return(-1); 
                          } 
                          
                          function yahoo64_decode($source) 
                          { 
                            $yahoo64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._"; 
                            $len=strlen($source); 
                            if($source[$len-1]=='-') { $plus=2; } 
                            if($source[$len-2]=='-') { $plus=1; } 
                            if($plus>0) { $len-=4; }; 
                          
                            $dest=""; 
                            for($i=0;$i<$len;$i+=4) 
                            { 
                              $chr1=Index($yahoo64,$source[$i]); 
                              $chr2=Index($yahoo64,$source[$i+1]); 
                              $chr3=Index($yahoo64,$source[$i+2]); 
                              $chr4=Index($yahoo64,$source[$i+3]); 
                              $dest.=chr(($chr1<<2)|($chr2>>4)); 
                              $dest.=chr((($chr2&0xF)<<4)|($chr3>>2)); 
                              $dest.=chr((($chr3&0x3)<<6)|($chr4&0x3F)); 
                            } 
                            switch($plus) 
                            { 
                              case 1: 
                              { 
                                $chr1=Index($yahoo64,$source[$i]); 
                                $chr2=Index($yahoo64,$source[$i+1]); 
                                $dest.=chr(($chr1<<2)|($chr2>>4)); 
                              } break; 
                              
                              case 2: 
                              { 
                                $chr1=Index($yahoo64,$source[$i]); 
                                $chr2=Index($yahoo64,$source[$i+1]); 
                                $chr3=Index($yahoo64,$source[$i+2]); 
                                $dest.=chr(($chr1<<2)|($chr2>>4)); 
                                $dest.=chr((($chr2&0xF)<<4)|($chr3>>2)); 
                              } break; 
                            } 
                            return($dest); 
                          } 
                          
                          //usage example 
                          
                          $string="any string"; 
                          print("Original string=$string<br>\n"); 
                          
                          $encoded=yahoo64_encode($string); 
                          print("Encoded string=$encoded<br>\n"); 
                          
                          $decoded=yahoo64_decode($encoded); 
                          print("Decoded string=$decoded<br>\n"); 
                          
                          //End PHP codes
                          
                          ?>

                          Comment

                          Working...
                          X