Thursday, November 11, 2010

Does anyone know how to program the addition of binary digits in VB 6?

I need to make a program in VB 6 that adds the binary digits of two text-Boxes. I made the conversion of decimal to binary, but don't know how to add the binaries now. I mean something like this: 01010010 + 0110101 = ?

I can do this by hand, but I need to program it! please help! 10pts.Thx!Does anyone know how to program the addition of binary digits in VB 6?
Basically you have to process both as strings.



If they are not the same length then you have to pad, on the left, the shorter string with 0's.



Once that is done then you move from the end to the start of the string looking at each pair of characters.



if str1[n] = '1' and str2[n] = '1' then

result[n] = '0'

if carry then result[n] = '1'

carry = true

else if (str1[n] = '1' and str2[n] = '0') or (str1[n] = '0' and str2[n] = '1') then

result[n] = '1'

if carry then

result[n] = '0'

carry = true

else

carry = false

end if

else

if carry then result[n] = '1' else result[n] = '0'

carry = false

end ifDoes anyone know how to program the addition of binary digits in VB 6?
Why do you have to add them together in binary? Why don't you just create a temporary variable for the decimal values, add them together and convert the sum back into binary?



I don't know if there is a built in function to do math with binary numbers; you could write one of course but that is dirty code, a waste of time. Why do it?



Unless you're in a programming class and they're making you do lame busy work; in which case that would be cheating helping you create the function.

How do you add duplicate integers in an Array in VB?

I have an array with 50 random integers, all ranging from 0 to 9(they are all displayed in one textbox). How can I add all the 1's together and display them in a label? Same with the 2's, 3's etc. Thanks!How do you add duplicate integers in an Array in VB?
There are many ways to skin a cat.



Here is another method which is compact and very efficient.



Create a second array called Total which has 10 elements. (VB initializes these to 0)

Dim Total(9) as integer (VB initializes these to 0)





Then loop through your original array reading the stored values (0 to 9). These values are then used as an index value to increment the appropriate element (0 to 9) in array Total.



For x = 0 to 49

idx = myArray(x) 'read the contents of the array

total(idx) = total(idx) + 1

next x





That's it.....How do you add duplicate integers in an Array in VB?
you can use a select case statement, and a loop. Since you knwo you have 50 numbers, the loop fwill need 50 intervals,

so

dim counter0,counter1,counter2,counter3,coun鈥?as intereger











for x = 0 to 49 (0 being the first index in the array)

{

select case array[x]

case 0:

counter0 = counter 0 + 1

case 1:

counter1 = counter 1 + 1

case 2:

counter2 = counter 2 + 1

case 3:

counter3 = counter 3 + 1

case 4:

counter4 = counter 4 + 1

case 5:

counter5 = counter 5 + 1

case 6:

counter6 = counter 6 + 1

case 7:

counter7 = counter 7 + 1

case 8:

counter8 = counter 8 + 1

case 9:

counter9 = counter9 + 1

}



label1.text = counter0



ect....

How can i connect a access 2000 database and vb over internet?

I can connect my access database over the LAN, but the connection string to connect vb6 and acces. Please help.How can i connect a access 2000 database and vb over internet?
give the ipaddress of the server.



or make dsn and give the folder user rightsHow can i connect a access 2000 database and vb over internet?
Try



http://www.connectionstrings.com/access
  • share hotel rental fee
  • How can i connect a access 2000 database and vb over internet?

    I can connect my access database over the LAN, but the connection string to connect vb6 and acces. Please help.How can i connect a access 2000 database and vb over internet?
    give the ipaddress of the server.



    or make dsn and give the folder user rightsHow can i connect a access 2000 database and vb over internet?
    Try



    http://www.connectionstrings.com/access

    How can I configure the connection string of a VB project in runtime?

    I am using the latest version of Visual Studio, programming in Visual Basic I can configure the Data Source in the Data Sources tab where the solution Explorer is, Then I can use the data with no problems.



    But I need to publish the project and install it on the client's computer, for which it needs to use a different connection string particulary to connect to the correct server and authenticate the user.



    How can this be done?How can I configure the connection string of a VB project in runtime?
    It depends on where the information is coming from. Pop up a form, asking the user for the server, user and login, read it from a text file, read it from the registry (write a little utility to write it to the registry when you install it), etc. Then read the information at runtime and use that to build the connection string. (It's a lot easier if you forget the controls, and just do the connection in pure code.)How can I configure the connection string of a VB project in runtime?
    It depends highly on the data source.

    http://www.connectionstrings.com/



    Generally, you use the System.data.Odbc data and do:



    String connString = ...ConnectionString...

    OdbcConnection conn = new OdbcConnection(connString);

    How to find the upper bounds of a dimension in a two dimensional array in vb.net?

    Example: Array(Dimension1, Dimension2). Find the upperbounds of Dimension1 and find the upperbounds of Dimension2.How to find the upper bounds of a dimension in a two dimensional array in vb.net?
    myArray.GetUpperBound(1)



    It's whatever dimension you want minus 1 as 0 is the always the first dimention

    How do I make a cut & paste VB code from one sheet to another in Excel based on a condition?

    I would like to enter data on the first sheet and depending on the value of one of the cells, have it moved to the appropriate sheet.



    For example,



    If the value of a cell is %26gt;= 10, then the entire row gets moved to Sheet X.

    If the value of a cell is %26gt;= 9 AND %26lt; 10, then the entire row gets moved to Sheet Y.





    And so on.



    Thanks in advance.How do I make a cut %26amp; paste VB code from one sheet to another in Excel based on a condition?
    Try this youtube channel - This guy has a lot of VBA for Excel video tutorials and some talk about copy/past values.How do I make a cut %26amp; paste VB code from one sheet to another in Excel based on a condition?
    In the VBA, you test the value in the cell(s) of interest, and if the value is 9, set the RANGE to the entire row, move it to the corresponding row in sheet Y. If the value is more than 9, move it to sheet X. You will have to trigger this code to execute when an event, such as the enter key is pressed.



    It isn't hard to do if you know some VBA.
    The results you get will be unsatisfactory when you go that route. VBA has to test for every key stroke and act without thinking. What if you made a mistake and need to undo?



    Instead why don't you go ahead and enter the data like any normal spreadsheet.



    Next look up features like autofilter which you can use to copy any filtered rows to another sheets. This way you are working on one original source without having to maintain separate worksheets.