Stop VB.net changing inputs like 01 to just 1? - vb.net

i'm struggling to find a solution to this. I am currently trying to take an input like 01 and keep it that way through the program, however VB.net seems to format that down to just 1. Is there any way to stop it doing this?
Thank you in advance, i'm sorry if this is just my stupidity.

If you want to keep it as "01" , you should store it in a string format not integer or any numerical data type. If you must use integers , you can display the output only in the format you want like this :
Dim int As Integer = 1
Console.Writeline(Format(int, "00"))
This should give you the output in the desired format. I hope that was helpful for you.

Related

VBA - conditional formatting with text

I was hoping that there is a way to conditionally format the column G like columns B & C. Possibly as binary, where the text = 1 and blank = 0? Thanks in advance.
Not exactly know the logic but here is a way to accomplish this with tweaking Custom Number Format. Here is the example and how I do it:
Determine your logic. See what I have in my example. I simply used 0 and 1 because Conditional Formatting works better with numbers.
Right click on the cell on column G, make a rule like [=0]"FAIL";[=1]"OKAY". Values inside [ ] is the condition, and the output string is inside the double quotes " ".
As for the Conditional Formatting, I believe you know what to do. Please let me know if this helps and good luck.

Adjusting number format using vb.net

I have this statement nested in an IF-Statement under a scenario. I would like it to format column 2 into a Accounting number without decimal places. How can this be done using VB.net? The current code gives me ex: 1,000,000.00 on an input of 1000000. I noticed excel has buttons for adding or subtracting decimal places. Could these be called within VB.net? Thanks!
Lo.ListColumns("Column2").DataBodyRange(CurrentRow).NumberFormat = "ACCOUNTING"
Try the following
Lo.ListColumns("Column2").DataBodyRange(CurrentRow).NumberFormat = "#0,000.00"
You may find help in this Article
From what i understand you want, you can do:
math.floor(*insert the value or variable you want here*)
What that does is it changes the number in the parameter to the biggest integer lower than the parameter.
Hope this works :)

Excel 2007 Text to Date

I need to change this in excel from Text to Date format and I want it to change from this:
Sep 30, 1985 12:00 AM
to this:
30/09/1985
I played around but I think I'm wasting a lot of time and hopefully you can assist me please, I would really appreciate it. I tried this:
=LEFT(SUBSTITUTE(A1,",",""),12)
and I get this:
Sep 30 1985
I was trying to break it down and then in the end figure out a way of converting from text to Date but I'm getting nowhere. Please advise if there is a way.
Kind regards
D
What about that:
The thing is that it's a bit complicated. Here you get date and then you can change format.
You can use the custom format to pick the format you like
Just ensure the format is date and it works, updated the screenshot as per your request

Newbie - datepicker and to string VB

I know this is a really basic question but i'm just starting with VB Studio and this is straight out of the book.
MsgBox("Your birth date was " & DateTimePicker1.Text)
MsgBox("Day of the year: " & DateTimePicker1.Value.DayOfYear.ToString())
I expected the ToString to convert the integer value to a text value of the date but it still returns the nummerical value. If I watch it is actaully returns the numercial value as a string eg "20". I have tried to find some info online but i get the same peice of code back that i'm using.
Are there compatabitiy issues with date picker and Win7 (64bit) or am i missing some simple configuration.
I'd appreciate any support on this simple problem.
Thank you
Damian
The ToString function does not convert integers to literal strings. It is use to convert objects or fields to Strings which are suitable for display. Therefore it convert the integer 2 to the string "2".
Try using custom format to get your date in the proper format
Look at this link to get started

How do I add a subscript to a string?

I need to add a subscript (a little number next to a character, like 2 or 3 - note: not a power of...) to a string [variable]. Is this possible? I don't want the code to be lengthy as I will need to process a lot of formulas, one at a time. Thanks.
You will have to use the character set subscript numbers. Strings do not contain formatting.
http://www.fileformat.info/info/unicode/char/2082/index.htm
Is this possible? No - string variables do not contain formatting.
In order to achieve this you will need to add some sort of formatting to your string and display it in something that can show different formats - for example a RichTextBox control
Try adding a RichTextBox control and running the following line:
RichTextBox1.Rtf = "{\rtf1\fbidis\ansi\ansicpg1252\deff0\deflang2057{\fonttbl{\f0\fswiss\fprq2\fcharset0 Calibri;}{\f1\fnil\fcharset0 Segoe UI;}}\viewkind4\uc1\pard\ltrpar\sa200\sl276\slmult1\f0\fs22 sometext\fs12 subscript\fs22\par\pard\ltrpar\f1\fs17\par}"
I don't claim to know what all the formatting is in here so I will leave you to figure that out yourself - hope that helps...