|
Hi,
if you build a "Console App" it gets started from a DOS prompt and will interact inside
the console; if double-clicked it will open its own console.
if you builw a "Windows App" it by default creates and opens a Form, because Visual Studio
includes a "Application.Run(new Form1())" in your main code; if you just use
"Application.Run()" then no form is created/shown.
Hence: choose Windows App, and omit the form.
|
|
|
|
|
I am taking over an application that consists of using ASP.NET and VB.NET. There are alot of hardcoded values in this application. What are the best practices and where is the best place to store these hardcoded values to get them out of the code?
Thanks in advance for you help.
|
|
|
|
|
caalock wrote: the best place to store these hardcoded values to get them out of the code?
With care. When you pull out hardcoded values and place them in the form of constants at the beginning of your code, make sure when you replace it in the code body, that it is indeed the same value. For example, if you have '1' hardcoded in your code, and in one case it works for '1', and you have to change it in the future, to say, '2', it may break something else.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
HI...
If it is a Database application then u can keep in a table...
U can also have them in a text file and read from there as in the case of configuration files
Good Luck
|
|
|
|
|
Hi,
you should put your constants where they belong, i.e. give them exactly the scope they
need. Examples:
- if you need the same constant a couple of times inside a single method, and never
outside it, then it deserves to become a named const at the top of that method;
- if you need the same constant a couple of times inside a single class, and never
outside it, then make it a const class member;
- if your constant is needed in more than one class, put it in some class, and let
the others refer it; never define the same constant more than once.
- if your constant is a general one, put it in a general-purpose class (see Math.Pi).
In all cases, try to give your constants meaningful names.
BTW: there is no need to use constants for numbers that can never change whatever happens;
if you want to iterate the elements of an array, go from 0 to Length-1, and don't make
that 0 a const int ZERO=0 !!
|
|
|
|
|
i had worket vb.net project.i am using msaccess database.how to give print in the form. plz give the sample code
advance thanks for your valuable replay
thanks & regords
velan
|
|
|
|
|
velan wrote: plz give the sample code
No. People around here tend not to do other people's work for them.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
velan wrote: i had worket vb.net project.i am using msaccess database.how to give print in the form. plz give the sample code
advance thanks for your valuable replay
So are you trying to print the Form itself (screenshot type thing), or are you trying to get the data from the MS Access Database into a Print Document, build a report, and then print it out (or is it something completely different)?
Pete Soheil
DigiOz Multimedia
http://www.digioz.com
|
|
|
|
|
Drop a MCL Form Print Component[^] on your form and set the settings for where and how you want the constituent parts (labels, text boxes, check boxes, etc. etc.) to print - then call the .Print method and it will print.
|
|
|
|
|
I need to read the value that is present at a specific address.
any Ideas?
thx in advance
BiG RaLpH
|
|
|
|
|
You can't just read any old address in the machine. Windows memory and process protections won't let you. When an application runs, it thinks it's the only application in the entire system. Each process get's it's own 2GB address space, so theres lots of room to play, even if the machine doesn't actually have 2GB of RAM in it.
If each process has its own address space, each process can be sitting in the same range of addresses. So how are you going to get one process to read another processes address space??
You have to Open the other process and read it, kind of like a file. But, not any user can open another process. You have to have admin rights to do this. For a C# example (can be converted to VB.NET), check out this article[^].
|
|
|
|
|
I agree with Dave. I suppose if it is too difficult to do something like that in VB.Net, you could write something in the Assembly language?
Lloyd J. Atkinson
"Logic will get you from A to B, but imagination will take you everywhere" -ALbert Einstein
|
|
|
|
|
I have to be able to detirmn how many weeks there are in a given year.
I'v searched the internet (google) and articles and forums here and found 2 links
http://konsulent.sandelien.no/VB_help/Week/ISO8601_VB.htm[^]
http://www.codeproject.com/KB/selection/MonthCalendar.aspx[^]
however these seem to suggest that there is no easy way to do this and also that there is no way I can simply pass the weeksystem and firstdayofweek alone and it will work
I can't believe that this isn't possible since it is in vba (access)
format(date,"ww",firstdayofweek,weeksystem) will return the correct number from the given date (if you give the date 31/12/2007 you'll get the number of weeks in 2007)
anyone know how I would go about this or do I really have to do it like the links suggest and make such a function for every weeksystem
any help will be appriciated
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistakes.
|
|
|
|
|
Try the DateDiff function.
Private Function getNumberOfWeeks(ByVal year As Integer) As Long
Dim d1 As Date = New Date(year, 1, 1)
Dim d2 As Date = New Date(Year, 12, 31)
Return DateDiff("w", d1, d2, FirstDayOfWeek.Monday)
End Function
Volker Weichert
|
|
|
|
|
you'r function seems to always return 52 weeks nomatter what year I give in (tryed it with year 2008 - 2017)
normally 2010 or 2009 should return 53
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistakes.
|
|
|
|
|
You can add another parameter to the DateDiff function that specifies when the first week of the year starts. Perhaps that can help. Other than that I can only think of getting the number of days between the first Monday of the year and the 31st December, divide it by 7 and round to the next higher integer. Then add another week depending on the number of days before the first Monday.
Private Function getNumberOfWeeks(ByVal year As Integer) As Integer
Dim daysBeforeFirstMonday As Integer = 8 - New Date(year, 1, 1).DayOfWeek()
If daysBeforeFirstMonday > 6 Then daysBeforeFirstMonday -= 7
Dim firstMonday As Date = New Date(year, 1, daysBeforeFirstMonday + 1)
Dim firstDayOfNewYear As Date = New Date(year + 1, 1, 1)
Dim weeks As Integer = Math.Floor(firstDayOfNewYear.Subtract(firstMonday).Days / 7)
If daysBeforeFirstMonday > 0 Then weeks += 1
Return weeks
End Function
The last part of the function has to be adjusted to your idea of the first week of the year.
Volker Weichert
|
|
|
|
|
Are you on about VB6 or VB.Net?
If it's VB.Net then this will work:
(sorry the code is in C# ... it should be easy to convert)
DateTime startOfYear = new DateTime(2008, 1, 1);
DateTime endOfYear = new DateTime(2008, 12, 31);
TimeSpan yearLength = endOfYear - startOfYear;
double numberOfWeeks = (yearLength.TotalDays / 7);
Console.WriteLine("Numbers of weeks: {0}", numberOfWeeks);
Console.ReadLine();
|
|
|
|
|
I am indeed talking about vb.net (I know how to do it in vba (vb6 probably is the same)) but it doesn't work anymore in vb.net
converting c# is no problem (I know it almost as good as vb.net)
you'r function seems to always return 52 weeks nomatter what year I give in (tryed it with year 2008 - 2017)
normally 2010 or 2009 should return 53
observation:
a year always has 364 or 365 days
364/7 = 52
365/7 = 52,142847142847142847...
so always 52
you might have misunderstood what I need
let me explain a bit more
in the world there are 3 kind of weeksystems
- week 1 is where 1/1/YYYY fals into
- week 1 is the first week of the year that has 4 full days in the new year
- week 1 is the first full week of the new year
and then there is also the posibility that the week starts at a different day
usually its monday but on occasion its sunday (or in extreem cases any other day)
so I need a function that takes this into account and looks if 31/12/YYYY is week 53 or 52
say 1/1/2008 is a thuesday (as it is now) then 2007 has 52 weeks (if start of week = monday or sunday)
say 1/1/2008 is a thursday (as 3/1/2008 is now) then 2007 has 52 weeks if start of week = monday but has 53 weeks if start of week = sunday
hope this helps a bit to explain what I'm trying to do
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistakes.
|
|
|
|
|
Ahhhh yeah I get you now.
You need to check out the stuff in System.Globalisation[^].
Here's a little example code on the usage, again forgive my C#
System.Globalization.GregorianCalendar gregorianCalendar = new System.Globalization.GregorianCalendar();
for (int i = 2000; i < 2020; i++)
{
DateTime endOfYear = new DateTime(i, 12, 31);
int numberOfWeeks = gregorianCalendar.GetWeekOfYear(endOfYear, System.Globalization.CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
Console.WriteLine("Year: {0} Number of Weeks: {1}", i, numberOfWeeks);
}
Console.ReadLine();
|
|
|
|
|
thank you this is helping alot
1 small remark it isn't always correct (I think, just had a quick glance at it)
for instance
gregorianCalendar.GetWeekOfYear(endofyear, System.Globalization.CalendarWeekRule.FirstDay, DayOfWeek.Monday)
will return 54 weeks for year 2012 (wich I think isn't right)
but it has sparked an idea on how I could do this
if it works I'll let you know
thanks again
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistakes.
|
|
|
|
|
I'd be very supprised if it didn't work correctly, although a bug in the framework is always possible, are you sure you have it setup correctly?
|
|
|
|
|
I can't be entirly sure that I did it correctly haven't had the time to thurly read the documentation you send me (will do that this weekend) but for as far as my understanding goes at the moment I think I did
I'll let you know what I find
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistakes.
|
|
|
|
|
Ok, well good luck
|
|
|
|
|
365 days, and 366 in leap years.
|
|
|
|
|
yeah sorry my mistake still it will not work since the number of weeks has nothing to do with wether or not it's a leap year but with what system one uses to detirmn the first week of the year (as explained above)
still trying to find a way to do this turned out the gregorian calander way helps but still needs some more coding
ah well I'll get there eventually
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistakes.
|
|
|
|