Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Change A Negative Number To Positive And Vice Versa

is this the correct manner in which to convert to negative and vice versa or could this cause problems of any sort...

lblDisplay.Caption = -Val(lblDisplay.Caption)

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Change Positive Number To Negative Number
Hello All Member,

How to write Change Positive Number to Negative Number using VB code.
Example : a = NegativeNumber(90)
                result ---> a = -90

I'm MeShto. (One of the world.)
Select * from vbcity where Member = 'MeShto';

How Do I Get A Negative Number To Become Positive?
is there some code that I can write so that like if I have -3 it auto maticly turns in into 3?

If Negative Then Change To Positive
hi, i have a question. Let say i have number1, number2 and number3. If I put like this:

number3 = number1 - number2

If number3 value is nagative then change the value into positif.

i hope this is clear enaugh..

How To Make A Negative Number Positive?
Hello people!

My first time posting here. The forum has been great, and I am confident I will get an answer on this question. Thanks in advance.

I have this negative number, let's call it "-32". I want to turn that into positive "32". But the number can change - sometimes its 64 or 128, and I want my code to just sort of flip it around to positive - or quite simply remove the substraction mark.

Is there a quick way to do this?

Oh, and the number is a Long.


Make A Positive Number - Negative
How do i make a positive number which is assigned to a variable, a negative one.


PA = (Aptelev) - (intDiffQ)

If intDiffQ was positive, how do i make it negative before storing it in PA. Is there a Function to it?

the reason I ask is because sometimes the value of Aptelev is -12 and the value of intDiffQ is Positive. I want the answer to be positive but i keep getting a negative number!

Any ideas?

Convert A Number Into A Hex String And Vice Versa?

I need a function that converts a decimal number into a hex string.
E.g.: 26 into "1A".

And then another function that re-converts "1A" into 26.

How could i do that?

Thank you!


How Ican CHANGE Negative To Positive
how ican CHANGE negative to positive
i need without - negative

Negative Or Positive?
How to check whether a number is Negative or positive? Is there any build in function to check?

hi, how do I take a integer, and if its positive, make it negative, and if its negative, make it positive?



Negative To Positive
I just know I'm going to sound completely ignorant, but how does one go about converting a negative integer to a positive?

Also, is it possible to move a number-only string (like 15) to an integer variable? Example:

Dim Blah as Integer
Dim BlahString as String

BlahString = "15"
Blah = BlahString

Obviously, VB chokes on this with a type mismatch. Any wisdom you could share would be helpful, thanks very much.

- Evan Sims

Hsltorgb And Vice Versa
i am trying to get the back color of the form which the user can specify and then i lighten a little of that color or darken that color and then implement it on my controls.
as i worked on it i came to know that vb give a long value of color and i cant increase of decrease light so what i did that i

vblong value > rgb > hls (change the light effect) hls > rgb > vblong value.

i have tried alot but i dont get a perfect color like if i dont change the light effect after getting hsl effect the color should be the same as form back color but this doesnt happen
any better idea or any help to for rgb to hsl and vice versa thanks

How To Get Domain Name From Ip And Vice Versa?

How can we get all the domain names from an ip and vice versa in vb?

Note- either in the software or code we should be able to give the dns server name which it has to contact for the lookups.


VB6 To Excel And Vice Versa
Hello Everybody,

Well I have 2 questions.

1) One problem with saving VB6 data in an excel file. Everything goes fine except that at the end I have 2 saved excel file name : "test" and "Workbook1".

Is there any solution so that I can have only one file with a name that I choose and the path I select through the dialog box after I click the command button and not only one name as default?

Here is my code

Private Sub mnusaveasxls_Click()

Dim j As Long

Dim obExcelApp As Object
Dim obWorkSheet As Object
Dim blnRunning As Boolean

On Error Resume Next

Set obExcelApp = GetObject(, "Excel.Application")

If Err.Number <> 0 Then

Set obExcelApp = CreateObject("Excel.Application")
blnRunning = False


blnRunning = True

End If


Set obWorkSheet = obExcelApp.ActiveSheet

"my code goes here"

obExcelApp.Save ("C: est.xls")

obExcelApp.ActiveWorkbook.Close False

If Not (blnRunning) Then


End If

End Sub
2) Can someone tell me how is it possible to read excel data with VB6, modify it and than save it again in another excel file?

Thank you in advance

Values From XLA To XLS And Vice-versa
I created an excel file with customized functions in vba. I use that functions in a lot of sheets and then the file becomes so big and sometimes takes a big time to recalcute it.
So I thought that if I transfer my functions and sheets to an AddIn and make a reference in my xls file to this xla, it should be a better solution.
I´ve made a xla, installed, reference to my main xls file, and so on...Everything is ok, except when I try to see in my xls some values that comes from xla, it doesn´t work. Or vice-versa, to put a value in xla that comes from xls.

Maybe is better to put an example.
In a cell A1 from main.xls I´d like to see a value from main.xla (cell B1, sheet named "Test").
Is there a special way to get that ? Or could only be done by vba because xla file is not visible ?

Thanks in advance,


Converting .wav To .mp3 And Vice-versa????
Can anybody tell me how to get the code to convert mp3 to wav or vice versa....
Better if it is in VB as the language I mostly understand is this one......
So pls help me find that code

Hex To Dec And Vice-versa With 2's Complement
I need to do conversions between hex and dec with 2's complement ...
I have to convert a DWORD (FFFF FFFF) to decimal with the complement.

With hex function of vb I get overflow when converting number above 4294967295 because it doesn't use 2's complement....

thanks in advance

Convert .csv To .mdb And Vice Versa
can anybody help me in converting .csv files to .mdb(access97) files and vice versa using visual basic 6?tnx

Positive And Negative In Integer
hi is there a command that make a integer positive no matter what i mean i got a command and i only want the positive of it to come out i know i can use a if after but i think that there a command that it put it at positive all the time i just can't remember it anyone know what it could be...

Positive And Negative In Calculator
how can I create the negative and positive functions in a calculator

Negative 2 Positive And Decimals
Hi, I need to know there are quicker ways to do the following :
- Is there a quick way to convert -110.00 to 110.00, and
- Is there a quick way to convert 110.00 11000

Any help would be appreciated!!


Base 10 To Binary And Vice Versa
Please help!
I am trying to make a program that when you input a number it outputs it on a label in it's binary form.
And vice versa.
ANY help would be much appreciated as I am running ou of time for this!

Converting C++ Projects Into VB 6.0 And Vice-Versa
I've got the source code of PODBot 2.6 for C++ developers. I understand VB 6 but I don't know anything about C++. There are programs to do this job?

Repetition Functions...dec To Bin(vice Versa)
hi, i have created a form consisting of 2 txtbox(txtDecimal & txtBinary) and 2 buttons(cmdToDecimal & cmdToBinary)

i am trying to convert dec to bin (and vice versa) according to what txtbox is inputted and which button is clicked. I have to do this task using repetition structure (For... Next and Do..Loop Unitl) and no built in functions following a psuedocode(see below). Can anyone please help me change the psuedocode to a function code(the use of iLen and Mid function is allowed).
--dec to bin--
set the bitstring to nothing
for each bit required in the bitstring
Calculate the remainder when the number is divided by 2
Number = Number 2 (integer division)
Bitstring = Remainder concatenated with the Bitstring
next bit
output the bitstring
--dec to bin--
set the bitstring to nothing
Calculate the remainder when the number is divided by 2
Number = Number 2 (integer division)
Bitstring = Remainder concatenated with the Bitstring
loop until Number is zero
output the bitstring
--bin to dec--
Number = 0
for each character in the bitstring
Determine the value of the bit
Number = Number * 2 + Value of the bit
next character (moving rightwards through the bitstring)
output the Number

i have also included a chkbox which restricts the bin conversion to 8bits.Anyone know how i can include this??

thanx in advance!!

Copying UDT To String And Vice Versa

I wanted to know if it is possible to copy a string to an user defined type and vice versa.

Let us say I have String "A" containing "1234567890" and a UDT with two String elements which can hold up to 5 characters. The problem is how to fill the first element with "12345" and the second one with "67890".

I know you can set the value to each element of the UDT "manually", but I wanted to know if it is possible to do it with CopyMemory. If yes, how? I tried the following code but it won't work:

Private Type myUDT
A As String * 5
B As String * 5
End Type
Private myUDTPointer As myUDT
Private myVar As String * 10

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)

Private Sub Form_Load()
myVar = "1234567890"
CopyMemory myUDTPointer, myVar, 20
End Sub

Convert Data Ucs-2 To Utf-8 And Vice Versa
Hi, All

I design a website using Utf-8. I use PHP and Mysql. Version Mysql 4.0.12-max-debug for Win95/Win98 on i32. But I want to convert Mysql data to Sql server 2000. I want to store utf-8 data in sql server. Unfortunately SQL server2000 and access use i different Unicode
encoding (UCS-2) and do not recognize UTF-8 as valid character data.

However, result of this function is not good.

How do i convert utf-8 to ucs-2 and vice versa? Can I help you an algorithm convert utf-8 to ucs-2 and vice versa? I want to code by Visual Basic

Sorry, my English is not well.

Thanks for all your help

Getting Ip Address From A Domain Name And Vice Versa?

For a given domain name how do we get ipaddress(viceversa) programatically in vb6. Is there any way to get them without using third party software products like Dart.


Ascii To Char &amp; Vice Versa
In VB 6.0 I have to make a simple program that convertas ASCII (ANSI) to the character & vice versa. I have to have a picbox, 2 cmd buttons, and of course the text box, I have all of them and they are all correctly labeled, i need help with the code. I cannot seem to get the code right, here is what I have put down so far...

Private Sub cmdValue_Click()
Dim Ascii As Integer
picOutput.Print "The ANSI Value "; txtInput.Text; " represents the charater"; KeyAscii
End Sub

Roman To Arabic And Vice Versa
Okay i know this is lame for all of u programers but for startes like myself,
I've done a pretty ugly jobe at this, but its working and all, just a few things
that i can't get right, anyways if anyone is able to do this for me, i'll
appreciate it alot !!

here is the thing...

================================================== =======

Roman numerals are still used for certain limited purposes such as copyright dates. The symbols used are I=1, V=5, X=10, C=100, D=500 & M=1000

One definition of roman numbers is
•The letters must be in descending order of value,
•The value of the number is the sum of all the letters,
•Each letter must be used a minimum number of times.

This is known as the additive rule & is the only rule to be used in this question.

For example

MCX = 1000 + 100 + 10 = 1110;
MXC is invalid because of wrong order;
IIII = 1 + 1 + 1 +1 = 4;
IIIII is invalid because it can be replaced with V.

A manufacturer wishes to make a new calculator that allows a user to input a number using roman numerals & displays the number in both Roman & Arabic forms.

The calculator must
•Allow a user to enter the roman numerals up to a value of 7000 (MMMMMMM),
•Prevent the user entering an invalid numeral,
•Display the number entered using roman numerals,
•Update this display as each roman numeral is entered,
•Display the number entered using Arabic numerals,
•Update this display as each roman numeral is entered,
•Allow the user to clear both displays, the roman number& the Arabic number.

================================================== =======

well if anyone can help me with this, i'll be thankful !
but if its too hard or something then never mind i dont want to take much of ur time..
if someone is kindly to do this for me, then i beg of u send me the vbs file !!
this would help me alot...

Functions For Converting Wav To Mp3 And Vice Versa
Are there any programs or something where you can convert mp3 to wav and vice versa?

Pass Value From Exe To Macro And Vice Versa
Can someone please help me?

I need to pass a count from macro to the executable and I have no idea how to do that.

I have to run this executable multiple times a day. The executable kicks off the macro. I want to pass the count from macro to executable.

i read somewhere that you can pass data from macro to exec. by using Return() function. but I have no idea how to use this. I couldn't find any online help with regards to this.

Also is there any way to tally the total count, from all the runs through out the day?

Any ideas, suggestions, comments, code samples will be appreciated.


Resolve Host By Ip And Vice Versa
I need to resolve the ip when I give the hostname and vice versa.
The problem:

I need the code for Windows CE 3.0

No Type command is supported and the API is smaller.

So - is there an easy way to do this?

P.S.: this must not check if a host or an ip is valid - just these two functions - that's enough.

thx, vbzero

How Do I Split One Drive Into Two Or Vice Versa?
I'm uh...making this visual basic program and errr...I need to know how to split one drive into multiple drives and take multiple drives and make them into one. For it to, you know, work.

I don't need it for a vb program. But I do need to know how to do it. It's just that you guys are so smart and it's so easy to get an answer around here! Please don't tell my mother...

[B]Enter Negative Or Positive Percent Value[/B]
I have some default values that can be overwritten and I need to provide the user an ability to overwrite the default value if desired. The big hang-up is the values are negative or positive percent values. Should I use a regular text box control (masked edit control is causing me dilemmas)?

Any suggestions?

Making A Negative Positive?[Solved]
Is there a function or something that turns a negative number into a positive, that is faster then if I would times the number by it's self, and square the result?

Convert Positive Decimal Into Negative
Hi All,

I am doing an Access 2000 using VBA. I encounterd problem
converting positive digit into negative one and vice versa.

The case is like this, I had a list box when the user chose
"withdrawal", the amount(in a textbox) will be a negative value. On the contrary, if user chose deposit, the value will remain "positive". Can someone help me with the code and or the function.

Thanks alot.

Converting Negative Values To Positive
I have written out some simple code that takes 2 values and then takes the quare root of the result, the problem is if the value is negative then the calculation obviously errors.

Is there a way of taking a difference of the 2 values (thus never receiving a negative value) or can you use a function to change any negative value to a positive. I have entered the code below:
result of Length2 - Length1 may be negative
XLdist = (Sqr((Yone - Ytwo) * (Yone - Ytwo) + (Xone - Xtwo) * (Xone - Xtwo))) / ShotPntNo

        Length1 = Sqr(((Xthree - Xone) * (Xthree - Xone)) + (Ythree - Yone) * (Ythree - Yone))
        Length2 = (XLone - XLthree + 1) * XLdist

ILdist = (Sqr((Length2 * Length2) - (Length1 * Length1))) / LineNo

Storing Byte Array To UDT And Vice-versa?
This may be a dumb question, but is it possible to automaticall read byte arrays into user-defined types, and vice-versa, similarly to interacting with Random file access and UDTs?

How To Re-sample Image Frm High Res To Low Res &amp; Vice Versa
how to re-sample images from high resolution to low resolution & vice versa in PictureBox? Lets say i hav a folder with image files & i wanna open them into an array of equal-size PictureBoxes. All the images hav diff sizes & resolutions, so how to display them nicely in the PictureBox while maintaining aspect ratio. We hav to use re-sampling, rite? Can anyone provide a code example on how to do tat?

i do not wanna use ImageBox control becos the stretch property will blow off the aspect ratio, hence i used PictureBox. Pls help. thanxs

Unix Timestamp To Date() And Vice Versa
Does anyone have a module that can get the current time in Unix Timestamp format and a function that can convert a unix timestamp to a normal date format.

Converting Pixels To Twips And Vice Versa...
If you could give me the equation, that would be wonderful. Or, if there is a function/operator that does the conversion, that would work, too.

Copying A List Box To A Combo Box And Vice Versa
i need on a form load to have a list box on the main form be copied to a combo box. thanks

Picture To Byte Array, Vice Versa

I know I have to change the picture into a byte array to send it and then change it back, BUT WHAT IS THE CODE FOR THIS????

I've been posting on these messageboards for 4 days with no Good response to this answer, Does anyone know the code or function to do this


Converting Binary To Decimal And Vice Versa
How can I convert a decimal to binary? I know how to on paper, keep dividing by 2, but how do I in VB?

How The Information From Database To Ms Excel And Vice Versa
      i dont know how to convert infromation from database to ms excel & vice versa.
i use ADO,in database i have 6 it convert it to excel sheet.
plz explain and give code


Synchronizing Ms Access From Server To Pda And Vice Versa??!!!!
may i know, can we use ms access 2000 as a database for pda application?
i use ms access in my server side but i'm not sure whether it can synchronize the database with the pda application.

How To Run A Vc++ User Developed Module From Vb Or Vice-versa
Hi There
Can any one of u pls help me. Tell me, is there a way out to run a vc++ developed code from vb. I have to make an installable version of my code also and I have a doubt that after I develop a module in vc it may not work with vb.
Please help me if u can.
Thanx in advance

Adding Positive &amp; Negative Numbers Separately
Hello All,

I have an excel sheet with a graph on it that plots a set of numbers that I have in column A. The numbers in the column are both positive and negative but I want to know if there is a way that I can have a cell display the sum of the negative numbers and the sum of the positive numbers separately in the cell range. The numbers I'm working with look something like this:


Again, I have two other cells next to the graph where I want to display the sum of only the positive numbers in the cell range and the sum of the negative numbers in the cell range. Are there any formulas or combination of formulas that I can use to calculate this assuming that the number range is everything in column A?

Jason O

Finding Positive &amp; Negative Peaks In Data

I'm trying to write some vba code in Excel to list the positive and negative peak values, in random data waveforms, for the last (n) peaks.

I've included a bitmap image of a typical graph of the data. It shows 5 positive and 5 negative peaks that I'm trying to capture within the waveform. I've used the sort command to try to follow the data, but it's not working out very well. Does anyone have any ideas ?

Copyright © 2005-08, All rights reserved