2017-02-14 75 views
0

我想创建一个注意到提醒一张纸条,这是我的代码:如何创建带有属性“ReminderTime”

'Create a note locally. 
Dim myNote As New Note() 

myNote.Title = "Sample note with Reminder set" 
myNote.Content = "Hello, world - this note has a Reminder on it." 
myNote.Attributes.ReminderTime = DateTime.Now.ToEdamTimestamp() 

'Create the note in the service, in the user's personal, default notebook. 
Dim store As ENNoteStoreClient =ENSessionAdvanced.SharedSession.PrimaryNoteStore 
Dim resultNote As Note = store.CreateNote(myNote) 

,但没有奏效。错误代码:

myNote.Attributes.ReminderTime = DateTime.Now.ToEdamTimestamp() 

全部细节:

未处理System.NullReferenceException的HResult = -2147467261 消息=未将对象引用设置到对象的实例

+0

可能重复[什么是NullReferenceException,以及如何解决它?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-doi-i-fix-它) –

+0

对不起,我不了解你。请你再详细解释一下吗? – 6lilu9

+0

'myNote.Attributes'可能为空 –

回答

1

音符的属性是一个NoteAttributes对象,因此您必须先创建对象:

'Create a note locally. 
Dim myNote As New Note() 

myNote.Title = "Sample note with Reminder set" 
myNote.Content = "Hello, world - this note has a Reminder on it." 

'Create the note's attributes. 
Dim myNoteAttributes As New NoteAttributes 

myNoteAttributes.ReminderTime = DateTime.Now.ToEdamTimestamp() 
myNote.Attributes = myNoteAttributes  

'Create the note in the service, in the user's personal, default notebook. 
Dim store As ENNoteStoreClient =ENSessionAdvanced.SharedSession.PrimaryNoteStore 
Dim resultNote As Note = store.CreateNote(myNote) 
+0

是的,它完美的工作,谢谢。我在哪里可以找到这样的一些教程? – 6lilu9

+0

不幸的是,没有任何教程可用于Evernote Windows SDK。但如果需要,你可以在这里提出更多问题。 –

+0

此外,由于我的答案适合您,如果您能够将我的答案标识为“接受的答案”,那将是非常好的。谢谢! –