Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
vb.net:获取字符串位置的奇怪行为_Vb.net - Fatal编程技术网

vb.net:获取字符串位置的奇怪行为

vb.net:获取字符串位置的奇怪行为,vb.net,Vb.net,批号是一个公共字符串 Dim myDelims As String() = New String() {"<beginning of record>"} split = temp_string.Split(myDelims, StringSplitOptions.None) For Each s As String In split If InStr(s, lot__no) <> 0 Then........... Dim my

批号是一个公共字符串

    Dim myDelims As String() = New String() {"<beginning of record>"}
    split = temp_string.Split(myDelims, StringSplitOptions.None)

    For Each s As String In split
        If InStr(s, lot__no) <> 0 Then...........
Dim myDelims As String()=新字符串(){”“}
split=temp_string.split(myDelims、StringSplitOptions.None)
对于拆分中的每个字符串
如果仪表(s,批号)为0,则。。。。。。。。。。。
所有这些代码都可以工作,除了出于某种原因在s中找不到lot____;no之外,即使在调试器中我检查了一切都应该正常工作

temp_字符串示例:

<beginning of record><Patient name>Alex Gordon</Patient name><Patient ID>1239871</Patient ID><Doc name>Dr. Bortz</Doc name><Lot no>928374</Lot no><highly intolerant>Blueberry*,*Cheddar Cheese*,*Chicken*,*Chili Pepper*,*Chocolate*,*Cinnamon*,*Clam*,*</highly intolerant><moderately>Beef*,*Broccoli*,*Codfish*,*Coffee*,*Cola nut*,*</moderately><lightly>Barley, Whole Grain*,*Buckwheat*,*Butter*,*Cabbage*,*Cane sugar*,*Cantaloupe*,*Carrot*,*Cashew*,*Cauliflower*,*Celery*,*</lightly><none>Almond*,*American Cheese*,*Apple*,*Avocado*,*Banana*,*Corn*,*Cottage Chesse*,*Cow's Milk*,*Crab*,*Cucumber*,*Egg, white/yolk*,*Eggplant*,*Garlic*,*Goat's Milk*,*Grape, White/Concord*,*Grapefruit*,*Green pea*,*Green pepper*,*Halibut*,*Honey*,*Lettuce, Iceberg*,*Lemon*,*Lima bean*,*Lobster*,*Malt*,*Millet*,*Mushroom*,*Mustard Seed*,*Oat*,*Olive*,*Onion*,*Orange*,*Oyster*,*Parsley*,*Peach*,*Peanut*,*Pinto bean*,*Pineapple*,*Pork*,*Potato*,*Rice*,*Rye*,*Safflower seed*,*Salmon*,*Sardine*,*Scallop*,*Sesame*,*Shrimp*,*Sole*,*Soybean*,*Spinach*,*Squashes*,*Strawberry*,*String bean*,*Sunflower seed*,*Sweet potato*,*Swiss Cheese*,*Tea, black*,*Tobacco*,*Tomato*,*Trout*,*Tuna*,*Turkey*,*Walnut, black*,*Wheat*,*Yeast, Baker's*,*Yeast, Brewer's*,*Yogurt*,*</none><beginning of record><Patient name>Patient Name</Patient name><Patient ID>Patient ID</Patient ID><Doc name>Doctor's Name</Doc name><Lot no>Lot #</Lot no><highly intolerant>Blueberry*,*</highly intolerant><moderately>Beef*,*</moderately><lightly>Barley, Whole Grain*,*</lightly><none>Almond*,*American Cheese*,*Apple*,*Avocado*,*Banana*,*Broccoli*,*Buckwheat*,*Butter*,*Cabbage*,*Cane sugar*,*Cantaloupe*,*Carrot*,*Cashew*,*Cauliflower*,*Celery*,*Cheddar Cheese*,*Chicken*,*Chili Pepper*,*Chocolate*,*Cinnamon*,*Clam*,*Codfish*,*Coffee*,*Cola nut*,*Corn*,*Cottage Chesse*,*Cow's Milk*,*Crab*,*Cucumber*,*Egg, white/yolk*,*Eggplant*,*Garlic*,*Goat's Milk*,*Grape, White/Concord*,*Grapefruit*,*Green pea*,*Green pepper*,*Halibut*,*Honey*,*Lettuce, Iceberg*,*Lemon*,*Lima bean*,*Lobster*,*Malt*,*Millet*,*Mushroom*,*Mustard Seed*,*Oat*,*Olive*,*Onion*,*Orange*,*Oyster*,*Parsley*,*Peach*,*Peanut*,*Pinto bean*,*Pineapple*,*Pork*,*Potato*,*Rice*,*Rye*,*Safflower seed*,*Salmon*,*Sardine*,*Scallop*,*Sesame*,*Shrimp*,*Sole*,*Soybean*,*Spinach*,*Squashes*,*Strawberry*,*String bean*,*Sunflower seed*,*Sweet potato*,*Swiss Cheese*,*Tea, black*,*Tobacco*,*Tomato*,*Trout*,*Tuna*,*Turkey*,*Walnut, black*,*Wheat*,*Yeast, Baker's*,*Yeast, Brewer's*,*Yogurt*,*</none><beginning of record><Patient name>Carter Smith</Patient name><Patient ID>id123123</Patient ID><Doc name>dr katz</Doc name><Lot no>lot293847</Lot no><highly intolerant>Barley, Whole Grain*,*</highly intolerant><moderately>Banana*,*Beef*,*</moderately><lightly>Avocado*,*Blueberry*,*</lightly><none>12*,*American Cheese*,*Apple*,*Broccoli*,*Buckwheat*,*Butter*,*Cabbage*,*Cane sugar*,*Cantaloupe*,*Carrot*,*Cashew*,*Cauliflower*,*Celery*,*Cheddar Cheese*,*Chicken*,*Chili Pepper*,*Chocolate*,*Cinnamon*,*Clam*,*Codfish*,*Coffee*,*Cola nut*,*Corn*,*Cottage Chesse*,*Cow's Milk*,*Crab*,*Cucumber*,*Egg, white/yolk*,*Eggplant*,*Garlic*,*Goat's Milk*,*Grape, White/Concord*,*Grapefruit*,*Green pea*,*Green pepper*,*Halibut*,*Honey*,*Lettuce, Iceberg*,*Lemon*,*Lima bean*,*Lobster*,*Malt*,*Millet*,*Mushroom*,*Mustard Seed*,*Oat*,*Olive*,*Onion*,*Orange*,*Oyster*,*Parsley*,*Peach*,*Peanut*,*Pinto bean*,*Pineapple*,*Pork*,*Potato*,*Rice*,*Rye*,*Safflower seed*,*Salmon*,*Sardine*,*Scallop*,*Sesame*,*Shrimp*,*Sole*,*Soybean*,*Spinach*,*Squashes*,*Strawberry*,*String bean*,*Sunflower seed*,*Sweet potato*,*Swiss Cheese*,*Tea, black*,*Tobacco*,*Tomato*,*Trout*,*Tuna*,*Turkey*,*Walnut, black*,*Wheat*,*Yeast, Baker's*,*Yeast, Brewer's*,*Yogurt*,*</none><beginning of record><Patient name>Patient Name</Patient name><Patient ID>Patient ID</Patient ID><Doc name>Doctor's Name</Doc name><Lot no>Lot #</Lot no><highly intolerant>Broccoli*,*Cane sugar*,*Cantaloupe*,*Carrot*,*Cashew*,*</highly intolerant><moderately>Blueberry*,*Buckwheat*,*Cabbage*,*Cheddar Cheese*,*Chicken*,*Chili Pepper*,*Chocolate*,*Cinnamon*,*</moderately><lightly>Beef*,*Butter*,*Cola nut*,*Corn*,*Cottage Chesse*,*Cow's Milk*,*</lightly><none>1*,*2*,*3*,*Avocado*,*Banana*,*Barley, Whole Grain*,*Cauliflower*,*Celery*,*Clam*,*Codfish*,*Coffee*,*Crab*,*Cucumber*,*Egg, white/yolk*,*Eggplant*,*Garlic*,*Goat's Milk*,*Grape, White/Concord*,*Grapefruit*,*Green pea*,*Green pepper*,*Halibut*,*Honey*,*Lettuce, Iceberg*,*Lemon*,*Lima bean*,*Lobster*,*Malt*,*Millet*,*Mushroom*,*Mustard Seed*,*Oat*,*Olive*,*Onion*,*Orange*,*Oyster*,*Parsley*,*Peach*,*Peanut*,*Pinto bean*,*Pineapple*,*Pork*,*Potato*,*Rice*,*Rye*,*Safflower seed*,*Salmon*,*Sardine*,*Scallop*,*Sesame*,*Shrimp*,*Sole*,*Soybean*,*Spinach*,*Squashes*,*Strawberry*,*String bean*,*Sunflower seed*,*Sweet potato*,*Swiss Cheese*,*Tea, black*,*Tobacco*,*Tomato*,*Trout*,*Tuna*,*Turkey*,*Walnut, black*,*Wheat*,*Yeast, Baker's*,*Yeast, Brewer's*,*Yogurt*,*</none>
Alex Gordon 1239871DR。Bortz928374蓝莓*,*切达奶酪*,*鸡肉*,*辣椒*,*巧克力*,*肉桂*,*蛤蜊*,*牛肉*,*花椰菜*,*鳕鱼*,*咖啡*,*可乐坚果*,*大麦,全麦*,*荞麦*,*黄油*,*卷心菜*,*蔗糖*,*哈密瓜*,*胡萝卜*,*腰果*,*花椰菜*,*芹菜*,*杏仁*,*美国奶酪*,*苹果*,*鳄梨*,*香蕉*,*玉米*,*,*牛奶*、*螃蟹*、*黄瓜*、*鸡蛋、蛋清/蛋黄*、*茄子*、*大蒜*、*羊奶*、*葡萄、白/康科德*、*葡萄柚*、*青豆*、*青椒*、*大比目鱼*、*蜂蜜*、*生菜、冰山*、*柠檬*、*利马豆*、*龙虾*、*麦芽*、*小米*、*蘑菇*、*芥末*、*燕麦*、*橄榄*、*洋葱*、*橙子*、*牡蛎*、*欧芹*、*花生*、*菠萝*、*菠萝*,*猪肉*,*土豆*,*大米*,*黑麦*,*红花籽*,*鲑鱼*,*沙丁鱼*,*扇贝*,*芝麻*,*虾*,*比目鱼*,*大豆*,*菠菜*,*南瓜*,*草莓*,*菜豆*,*葵花籽*,*红薯*,*瑞士奶酪*,*茶,黑*,*烟草*,*番茄*,*鳟鱼*,*金枪鱼*,*火鸡*,*核桃,黑*,*小麦*,*酵母*,*面包*,*酵母*,*啤酒*,*酸奶*,*,*患者姓名患者ID医生姓名:蓝莓*、*牛肉*、*大麦、全麦*、*杏仁*、*美国奶酪*、*苹果*、*鳄梨*、*香蕉*、*西兰花*、*荞麦*、*黄油*、*卷心菜*、*蔗糖*、*哈密瓜*、*胡萝卜*、*腰果*、*花椰菜*、*芹菜*、*切达奶酪*、*鸡肉*、*辣椒*、*巧克力*、*肉桂*、*蛤蜊*、*鳕鱼*、*咖啡*、*坚果*,*玉米*、*农舍芝士*、*牛奶*、*螃蟹*、*黄瓜*、*鸡蛋、白/蛋黄*、*茄子*、*大蒜*、*羊奶*、*葡萄、白/康科德*、*葡萄柚*、*青豆*、*大比目鱼*、*蜂蜜*、*莴苣、冰山*、*柠檬*、*利马豆*、*龙虾*、*麦芽*、*小米*、*蘑菇*、*芥末*、*燕麦*、*橄榄*、*洋葱*、*橘子*、*牡蛎*、*香菜*、*花生*,*粉豆*、*菠萝*、*猪肉*、*土豆*、*大米*、*黑麦*、*红花籽*、*鲑鱼*、*沙丁鱼*、*扇贝*、*芝麻*、*虾*、*鞋底*、*大豆*、*菠菜*、*南瓜*、*草莓*、*菜豆*、*葵花籽*、*红薯*、*瑞士奶酪*、*茶、黑*、*烟草*、*番茄*、*鳟鱼*、*金枪鱼*、*火鸡*、*核桃、黑*、*小麦*、*酵母*、*面包*、*啤酒*,*酸奶*,*卡特·史密斯123123123DR卡兹洛特293847大麦,全麦*,*香蕉*,*牛肉*,*鳄梨*,*蓝莓*,*12*,*美国奶酪*,*苹果*,*西兰花*,*荞麦*,*黄油*,*卷心菜*,*蔗糖*,*哈密瓜*,*胡萝卜*,*腰果*,*花椰菜*,*芹菜*,*切达奶酪*,*鸡肉*,*辣椒*,*巧克力*,*肉桂*,*蛤蜊*,*鳕鱼*,*咖啡*,*坚果*,*,*玉米*、*农舍芝士*、*牛奶*、*螃蟹*、*黄瓜*、*鸡蛋、白/蛋黄*、*茄子*、*大蒜*、*羊奶*、*葡萄、白/康科德*、*葡萄柚*、*青豆*、*大比目鱼*、*蜂蜜*、*莴苣、冰山*、*柠檬*、*利马豆*、*龙虾*、*麦芽*、*小米*、*蘑菇*、*芥末*、*燕麦*、*橄榄*、*洋葱*、*橘子*、*牡蛎*、*香菜*、*花生*,*粉豆*、*菠萝*、*猪肉*、*土豆*、*大米*、*黑麦*、*红花籽*、*鲑鱼*、*沙丁鱼*、*扇贝*、*芝麻*、*虾*、*鞋底*、*大豆*、*菠菜*、*南瓜*、*草莓*、*菜豆*、*葵花籽*、*红薯*、*瑞士奶酪*、*茶、黑*、*烟草*、*番茄*、*鳟鱼*、*金枪鱼*、*火鸡*、*核桃、黑*、*小麦*、*酵母*、*面包*、*啤酒*,*酸奶*,*患者姓名*患者姓名*医生姓名*西兰花*,*蔗糖*,*哈密瓜*,*胡萝卜*,*腰果*,*蓝莓*,*荞麦*,*卷心菜*,*切达奶酪*,*鸡肉*,*红辣椒*,*巧克力*,*肉桂*,*牛肉*,*黄油*,*可乐坚果*,*玉米*,*乡村樱桃*,*牛奶*,*1*,*2*,*3*,*鳄梨*,*香蕉*,*大麦*,*全麦*,*椰菜*,*椰菜*,*蛤,*鳕鱼*、*咖啡*、*螃蟹*、*黄瓜*、*鸡蛋、白/蛋黄*、*茄子*、*大蒜*、*羊奶*、*葡萄、白/康科德*、*葡萄柚*、*青豆*、*青椒*、*大比目鱼*、*蜂蜜*、*莴苣、冰山*、*柠檬*、*利马豆*、*龙虾*、*麦芽*、*小米*、*蘑菇*、*芥末籽*、*燕麦*、*橄榄*、*洋葱*、*橙子*、*牡蛎*、*欧芹*、*桃子*、*花生*、*红豆*、*,*菠萝*,*猪肉*,*土豆*,*大米*,*黑麦*,*红花籽*,*鲑鱼*,*沙丁鱼*,*扇贝*,*芝麻*,*虾*,*鞋底*,*大豆*,*菠菜*,*南瓜*,*草莓*,*菜豆*,*葵花籽*,*红薯*,*瑞士奶酪*,*茶,黑*,*烟草*,*西红柿*,*鳟鱼*,*金枪鱼*,*火鸡*,*核桃,黑*,*小麦*,*酵母,面包*,*酵母*,*啤酒*,**
有人知道为什么一个字符串在另一个字符串中没有被检测到吗

这个问题比你们想象的要深,因为我知道代码是好的

谢谢大家的意见,但不幸的是,这没有什么帮助。我仍然有问题

lot\uu no=“lot no>928374”

那我就去

if s.indexof(lot__no) >= 0 then
   'do stuff
end if
但是,由于您似乎在使用xml,因此应该使用内置的.NETXML解析器


不要构建自己的应用程序

尝试此命令行应用程序。为我工作

Module Module1

    Sub Main()
        Dim temp_string As String = "<beginning of record><Patient name>Alex Gordon</Patient name><Patient ID>1239871</Patient ID><Doc name>Dr. Bortz</Doc name><Lot no>928374</Lot no><highly intolerant>Blueberry*,*Cheddar Cheese*,*Chicken*,*Chili Pepper*,*Chocolate*,*Cinnamon*,*Clam*,*</highly intolerant><moderately>Beef*,*Broccoli*,*Codfish*,*Coffee*,*Cola nut*,*</moderately><lightly>Barley, Whole Grain*,*Buckwheat*,*Butter*,*Cabbage*,*Cane sugar*,*Cantaloupe*,*Carrot*,*Cashew*,*Cauliflower*,*Celery*,*</lightly><none>Almond*,*American Cheese*,*Apple*,*Avocado*,*Banana*,*Corn*,*Cottage Chesse*,*Cow's Milk*,*Crab*,*Cucumber*,*Egg, white/yolk*,*Eggplant*,*Garlic*,*Goat's Milk*,*Grape, White/Concord*,*Grapefruit*,*Green pea*,*Green pepper*,*Halibut*,*Honey*,*Lettuce, Iceberg*,*Lemon*,*Lima bean*,*Lobster*,*Malt*,*Millet*,*Mushroom*,*Mustard Seed*,*Oat*,*Olive*,*Onion*,*Orange*,*Oyster*,*Parsley*,*Peach*,*Peanut*,*Pinto bean*,*Pineapple*,*Pork*,*Potato*,*Rice*,*Rye*,*Safflower seed*,*Salmon*,*Sardine*,*Scallop*,*Sesame*,*Shrimp*,*Sole*,*Soybean*,*Spinach*,*Squashes*,*Strawberry*,*String bean*,*Sunflower seed*,*Sweet potato*,*Swiss Cheese*,*Tea, black*,*Tobacco*,*Tomato*,*Trout*,*Tuna*,*Turkey*,*Walnut, black*,*Wheat*,*Yeast, Baker's*,*Yeast, Brewer's*,*Yogurt*,*</none><beginning of record><Patient name>Patient Name</Patient name><Patient ID>Patient ID</Patient ID><Doc name>Doctor's Name</Doc name><Lot no>Lot #</Lot no><highly intolerant>Blueberry*,*</highly intolerant><moderately>Beef*,*</moderately><lightly>Barley, Whole Grain*,*</lightly><none>Almond*,*American Cheese*,*Apple*,*Avocado*,*Banana*,*Broccoli*,*Buckwheat*,*Butter*,*Cabbage*,*Cane sugar*,*Cantaloupe*,*Carrot*,*Cashew*,*Cauliflower*,*Celery*,*Cheddar Cheese*,*Chicken*,*Chili Pepper*,*Chocolate*,*Cinnamon*,*Clam*,*Codfish*,*Coffee*,*Cola nut*,*Corn*,*Cottage Chesse*,*Cow's Milk*,*Crab*,*Cucumber*,*Egg, white/yolk*,*Eggplant*,*Garlic*,*Goat's Milk*,*Grape, White/Concord*,*Grapefruit*,*Green pea*,*Green pepper*,*Halibut*,*Honey*,*Lettuce, Iceberg*,*Lemon*,*Lima bean*,*Lobster*,*Malt*,*Millet*,*Mushroom*,*Mustard Seed*,*Oat*,*Olive*,*Onion*,*Orange*,*Oyster*,*Parsley*,*Peach*,*Peanut*,*Pinto bean*,*Pineapple*,*Pork*,*Potato*,*Rice*,*Rye*,*Safflower seed*,*Salmon*,*Sardine*,*Scallop*,*Sesame*,*Shrimp*,*Sole*,*Soybean*,*Spinach*,*Squashes*,*Strawberry*,*String bean*,*Sunflower seed*,*Sweet potato*,*Swiss Cheese*,*Tea, black*,*Tobacco*,*Tomato*,*Trout*,*Tuna*,*Turkey*,*Walnut, black*,*Wheat*,*Yeast, Baker's*,*Yeast, Brewer's*,*Yogurt*,*</none><beginning of record><Patient name>Carter Smith</Patient name><Patient ID>id123123</Patient ID><Doc name>dr katz</Doc name><Lot no>lot293847</Lot no><highly intolerant>Barley, Whole Grain*,*</highly intolerant><moderately>Banana*,*Beef*,*</moderately><lightly>Avocado*,*Blueberry*,*</lightly><none>12*,*American Cheese*,*Apple*,*Broccoli*,*Buckwheat*,*Butter*,*Cabbage*,*Cane sugar*,*Cantaloupe*,*Carrot*,*Cashew*,*Cauliflower*,*Celery*,*Cheddar Cheese*,*Chicken*,*Chili Pepper*,*Chocolate*,*Cinnamon*,*Clam*,*Codfish*,*Coffee*,*Cola nut*,*Corn*,*Cottage Chesse*,*Cow's Milk*,*Crab*,*Cucumber*,*Egg, white/yolk*,*Eggplant*,*Garlic*,*Goat's Milk*,*Grape, White/Concord*,*Grapefruit*,*Green pea*,*Green pepper*,*Halibut*,*Honey*,*Lettuce, Iceberg*,*Lemon*,*Lima bean*,*Lobster*,*Malt*,*Millet*,*Mushroom*,*Mustard Seed*,*Oat*,*Olive*,*Onion*,*Orange*,*Oyster*,*Parsley*,*Peach*,*Peanut*,*Pinto bean*,*Pineapple*,*Pork*,*Potato*,*Rice*,*Rye*,*Safflower seed*,*Salmon*,*Sardine*,*Scallop*,*Sesame*,*Shrimp*,*Sole*,*Soybean*,*Spinach*,*Squashes*,*Strawberry*,*String bean*,*Sunflower seed*,*Sweet potato*,*Swiss Cheese*,*Tea, black*,*Tobacco*,*Tomato*,*Trout*,*Tuna*,*Turkey*,*Walnut, black*,*Wheat*,*Yeast, Baker's*,*Yeast, Brewer's*,*Yogurt*,*</none><beginning of record><Patient name>Patient Name</Patient name><Patient ID>Patient ID</Patient ID><Doc name>Doctor's Name</Doc name><Lot no>Lot #</Lot no><highly intolerant>Broccoli*,*Cane sugar*,*Cantaloupe*,*Carrot*,*Cashew*,*</highly intolerant><moderately>Blueberry*,*Buckwheat*,*Cabbage*,*Cheddar Cheese*,*Chicken*,*Chili Pepper*,*Chocolate*,*Cinnamon*,*</moderately><lightly>Beef*,*Butter*,*Cola nut*,*Corn*,*Cottage Chesse*,*Cow's Milk*,*</lightly><none>1*,*2*,*3*,*Avocado*,*Banana*,*Barley, Whole Grain*,*Cauliflower*,*Celery*,*Clam*,*Codfish*,*Coffee*,*Crab*,*Cucumber*,*Egg, white/yolk*,*Eggplant*,*Garlic*,*Goat's Milk*,*Grape, White/Concord*,*Grapefruit*,*Green pea*,*Green pepper*,*Halibut*,*Honey*,*Lettuce, Iceberg*,*Lemon*,*Lima bean*,*Lobster*,*Malt*,*Millet*,*Mushroom*,*Mustard Seed*,*Oat*,*Olive*,*Onion*,*Orange*,*Oyster*,*Parsley*,*Peach*,*Peanut*,*Pinto bean*,*Pineapple*,*Pork*,*Potato*,*Rice*,*Rye*,*Safflower seed*,*Salmon*,*Sardine*,*Scallop*,*Sesame*,*Shrimp*,*Sole*,*Soybean*,*Spinach*,*Squashes*,*Strawberry*,*String bean*,*Sunflower seed*,*Sweet potato*,*Swiss Cheese*,*Tea, black*,*Tobacco*,*Tomato*,*Trout*,*Tuna*,*Turkey*,*Walnut, black*,*Wheat*,*Yeast, Baker's*,*Yeast, Brewer's*,*Yogurt*,*</none>"

        Dim lot__no As String = "lot293847"
        Dim split As String()

        Dim myDelims As String() = New String() {"<beginning of record>"}
        Split = temp_string.Split(myDelims, StringSplitOptions.None)

        For Each s As String In split
            If s.Contains(lot__no) Then
            'Either If statement seems to work as expected
            'If InStr(s, lot__no) <> 0 Then
                Console.WriteLine("found lot# " & lot__no & " in the following string")
                Console.WriteLine(s)
                Console.WriteLine()
            End If

        Next

        Console.WriteLine()
        Console.WriteLine("Press a key...")
        Console.ReadKey()
    End Sub

End Module
模块1
副标题()
Dim temp_字符串作为字符串=“Alex Gordon 1239871博士。Bortz928374蓝莓*,*切达奶酪*,*鸡肉*,*辣椒*,*巧克力*,*肉桂*,*蛤蜊*,*牛肉*,*花椰菜*,*鳕鱼*,*咖啡*,*可乐坚果*,*大麦,全麦*,*荞麦*,*黄油*,*卷心菜*,*蔗糖*,*哈密瓜*,*胡萝卜*,*腰果*,*花椰菜*,*芹菜*,*杏仁*,*美国奶酪*,*苹果*,*鳄梨*,*香蕉*,*玉米*,*,*牛奶*、*螃蟹*、*黄瓜*、*鸡蛋、蛋清/蛋黄*、*茄子*、*大蒜*、*羊奶*、*葡萄、白/康科德*、*葡萄柚*、*青豆*、*青椒*、*大比目鱼*、*蜂蜜*、*生菜、冰山*、*柠檬*、*利马豆*、*龙虾*、*麦芽*、*小米*、*蘑菇*、*芥末*、*燕麦*、*橄榄*、*洋葱*、*橙子*、*牡蛎*、*欧芹*、*花生*、*菠萝*、*菠萝*,*猪肉*,*土豆*,*大米*,*黑麦*,*红花籽*,*鲑鱼*,*沙丁鱼**
Sub Main()
  Dim temp_string = "<beginning of record> blah lot123 <beginning of record>lot123"
  Dim lot__no = "lot123"

  Dim myDelims As String() = New String() {"<beginning of record>"}
  Dim Split = temp_string.Split(myDelims, StringSplitOptions.None)

  For Each s As String In Split
    If InStr(s, lot__no) <> 0 Then
      Console.WriteLine(String.Concat("found it in ", s))
    End If
  Next
End Sub
If Regex.IsMatch(s, lot__no) Then ...