Remove dot´s from date - vb.net

I made a program that generates a daily index code.
It gets created from
Employer (everyone has a number from 0-9)
Date of serial code requested
Everything is working fine, but I wannt to remove the dots from the date
I tried things like
date.Text = date.Text.Replace(".""", """")
or
Dim clean as String
clean = myString.Replace(".", "")
But nothing happens
May be I just didnt unterstand the using... If yes, so please help me to find a alternative.
Ok i will try to explain better.
As I lunch it a textbox gets the date of today, the textbox is called date
Ive got a combobox, from there you select the employer. Every employer has a number. For example Andreas is Number 1.
I wannt to do something like:
if combobox1.text = "Andreas" then
dailyCode.text = "1" & date.text
end if
My problem is that the date is written with dots, the daily code should not have dots.
Sorry for my bad English

In your questions Details are still incomplete.still assuming that the date(still i am confused how are you using reserved keyword) is declared as date type itself,consider formatting it with Format function itself.
Try using
Dim s As String = Format(date, "ddMMMyyyy")
hope that helps.

Related

Write to Date Time Picker

Today, I want to write day, month, and year to a datetimepicker in Visual Studio.
cmd.Parameters.AddWithValue("#geboortedag", dtp_geboortedatum.Value.Day)
cmd.Parameters.AddWithValue("#geboortemaand", dtp_geboortedatum.Value.Month)
cmd.Parameters.AddWithValue("#geboortejaar", dtp_geboortedatum.Value.Year)
These work. I save day, month and year separately to three rows in my database.
However, when I want to call these values, I can't even run the thing without getting the following:
BC30068 Visual Basic AND VB.NET Expression is a value and therefore cannot be the target of an assignment.
Here's what I tried.
dtp_geboortedatum.Value.Day = row("geboortedag").ToString
dtp_geboortedatum.Value.Month = row("geboortemaand").ToString
dtp_geboortedatum.Value.Year = row("geboortejaar").ToString
All I want is to put the day, month and year I have in separate cells into the date time picker when I open a record.
PS I also tried like the help page for the error says to write to a variable first but that does nothing to help. Perhaps I did it wrong but, I can't get it to work.
Also, I've been linked to this article but this does not fix the issue. I keep getting errors that integers are strings and cannot be converted to integers, but they're integers! They're integers when they start, they're integers when they're saved into a row for integers that saves integers, they're integers when they come out. Why aren't they integers in the end when nothing special happens to them but being inputted, saved, and called?
(Posted on behalf of the question author).
None of the material I provided in the question is relevant. Turns out I had to use dt.clear(). I'm going to be honest, I don't know how this is the thing that went wrong.
I fixed the rest with cdate() and Option Strict On.
its a very long time since touched VB.NET, but I think what you need to do is pass a DateTime type to the date picker to set its value as below;
dtp_geboortedatum.Value = New DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day)
So you will need to pass your year, month and day as integers
Just substitute your row integer values for the literals I used.
Private Sub SetDate()
Dim myDay As Integer = 27
Dim myMonth As Integer = 4
Dim myYear As Integer = 2018
DateTimePicker1.Value = New DateTime(myYear, myMonth, myDay)
End Sub

VBA Outlook 2010. Extracting specific outlook body text to excel

There are a few posts open on this topic however none seem to fully do what I need. I have done a little bit of programming however I have never done anything with VBA. Every day I receive a series of emails varying from 10 to 50 all containing a subject line starting with [Tk#*******] New Request ( * = 7 digit number)
Then inside the body text there is a form that looks like this:
Body Text
I then have an excel sheet set up with 'Username' in 'C', 'Company' in 'G', 'valid until' in 'H' and 'Ticket' in 'I'. I would like to extract first the 7 digit ticket number from the subject and put it in the excel 'Ticket' field, then just the 'smithjoh' part from the login field and place it in 'Username', then the External company listed to 'Company' and finally the Expiration date into 'valid until'.
First I would like to know if this is possible to do as it is extracting specific sections of the data and if so if someone could help me out with making this work that'd be most appreciated. I have attempted to do it myself however lack of experience has left me clueless therefor there is nothing to work with unfortunately. If this could be made it would help me out a lot as it would automate a very tedious manual task.
Thanks,
Mark
Ok, if you are grabbing the body and title without issue then you just need to do string manipulations. Read them into a variable each. Assuming that your subject is litterally "TK#******* New Request" then this should get you started. Basically repeat this logic for each part you want to pull out. Once you have the values in variables you can then put those values into cells.
Dim sSubject as string
Dim sBody as string
Dim sTicket as string
Dim sLogin as string
Dim lLoginPos as long
Dim iLoginLength as integer
sTicket = Mid(sSubject,4,7) 'start 4th char and grab 7 ... if you actually have the brackets in the subject then do 5,7
lLoginPos = InStr(sBody, "emea") + 5 'if they aren't all emea you will need to key off the "Req on behalf name" and add more to the result the result will be the e in emea so add 5 to get past that to the login.
iLoginLength = InStr(sBody, "Req on behalf mail") - lLoginPos ' you might need to subtract an additional 1 or 2 if your result isn't perfect. Not sure what the blank white spaces in your screenshot will do here.
sLogin = Mid(sBody,lLoginPos,iLoginLength) ' grabs that username.
With Sheets("Sheet1")
cells(1,3) = sLogin ' puts that into Row 1 Colum 3 (C) Cells is R1C1 ... backwards from the normal way you think of excel
End With
Use other string variables for all the other parts you want to grab and just repeat the logic of finding the starting place and ending place and then using mid to put it into a variable.
Give it a shot filling out the rest and if you get stuck, post your code up to that point and let us know what line is giving you trouble. Don't forget to turn on your locals window and use your F8 key to step through the code one line at a time so that you can see exactly what is going on. This is especially useful with string manipulations.

How to find day of the week from known date and month but variable year

My code so far is this:
intYear = CDate(varYear)
intJan = Weekday("1/1/" & intYear)
varYear is a variant that has been tested to be a valid number.
The problem is in line two, it doesn't like me trying to merge the date and month to the variable year, is there another way around this?
Edit:
I have since changed the code to this:
varJan = ("1/1/" & varYear)
intJan = Weekday(CDate(varJan))
It is still having trouble, it's saying there's a type mismatch. I know the issue is steaming again from the second line.
The solution was found by eliminating unnecessary variables and thus eliminating potential conversion problems.
The final code was as follows:
intJan = Weekday(CDate("1/1/" & varYear))

DateAdd + DLookup

I am requesting some guidance to fix this problem I have been having while trying to edit the "AfterUpdate" event in my database. It seems to work fine on my local machine but when I try to implement it in the network database it doesn't work properly (occasionally puts in a random date in one of the fields, doesn't erase the date when I supply a new ID, etc.)
Here is the VBA Code I have:
Private Sub provider_surveyID_AfterUpdate()
provider_survey_dueDate = DateAdd("ww", 2, DLookup("completed_on",
"qry_ProviderSurveyInfo", "provider_surveyID=" & provider_surveyID))
provider_survey_reminder2weeks = DateAdd("ww", 4, DLookup("completed_on",
"qry_ProviderSurveyInfo", "provider_surveyID=" & provider_surveyID))
provider_survey_reminder4weeks = DateAdd("ww", 6, DLookup("completed_on",
"qry_ProviderSurveyInfo", "provider_surveyID=" & provider_surveyID))
End Sub
The query is correct, joining the Survey ID to the appropriate participant to determine the original "completed_on" date that is used in the DateAdd functions.
Can you see any reason why it would not work as it does on local - removing dates when entering IDs currently not in use? Also, think it would be wise to use Nz(provider_surveyID,0) in this instance? I haven't implemented it yet as I wanted to make it work appropriately as it does on my local with no issues whatsoever - I enter for the ID, it populates; I enter 20 (not in use yet), it makes all dates null again.
Dlookups can be slow and tricky to use, it will also return random values when the Criteria isn't entered. I'm not sure on how your form is put together (I'm assuming it's a form), and this may be a partial answer:
Private Sub provider_surveyID_AfterUpdate()
Dim dtComplete as Date
If IsNull(provider_serveyID) then
provider_survey_dueDate=""
provider_survey_reminder2weeks=""
provider_survey_reminder4weeks=""
Else
dtComplete = DLookup("completed_on","qry_ProviderSurveyInfo", "provider_surveyID=" & provider_surveyID)
provider_survey_dueDate=DateAdd("ww",2,dtComplete)
provider_survey_reminder2weeks=DateAdd("ww",4,dtComplete)
provider_survey_reminder4weeks=DateAdd("ww",6,dtComplete)
End if
End sub

VS 2010 macro - select from here to there

I'm writing a macro to let me replace the spaces in a string in my code file with underscores. I've gotten as far as finding the beginning and end of the string as instances of VirtualPoint. Now I'm trying to select from the first VirtualPoint to the second. And I can't figure it out.
I know the VirtualPoints are correct, because I'm using MessageBox.Show to tell me their values when I run the macro. I just don't know the correct command to set the TextSelection from the first to the second. I've tried this:
selection.MoveToPoint(firstVirtualPoint)
selection.MoveToPoint(secondVirtualPoint, True)
This seems like it ought to work, but it doesn't. The cursor just moves to the end of the line (as far as I can tell).
Does anybody know the correct command for doing this?
As these things tend to go, after I give up, suddenly it hits me. Perhaps this will help someone else, though.
A fuller sample of the code is this:
Dim selection As TextSelection =
CType(DTE.ActiveDocument.Selection, TextSelection)
selection.StartOfLine()
selection.FindText("some string at start")
Dim pointAfterStart = selection.BottomPoint
selection.FindText("some string at end")
Dim pointBeforeEnd = selection.TopPoint
selection.MoveToPoint(pointAfterIt)
selection.MoveToPoint(pointBeforeLambda, True)
The idea is to find the initial text, then the ending text, and then select everything in between. What I found in the debugger was that the values in pointAfterStart and pointBeforeEnd were changing. Perhaps deceived by the name (since System.Drawing.Point is a struct), I wasn't realizing they were references that pointed to the current selection position.
I solved it this way:
selection.FindText("It ")
Dim pointAfterIt = selection.BottomPoint.CreateEditPoint
selection.FindText(" = () =>")
Dim pointBeforeLambda = selection.TopPoint.CreateEditPoint
This made copies of the selection points, so that they didn't change when the selection moved later.